This seems very slow:
julia> @time cheb2leg(randn(1_000));
0.014712 seconds (9 allocations: 16.438 KiB)
julia> @time cheb2leg(randn(10_000));
0.491001 seconds (11 allocations: 156.969 KiB)
julia> @time cheb2leg(randn(100_000));
8.688441 seconds (11 allocations: 1.527 MiB)
This seems very slow: