AFAIK, and someone can correct me if I'm wrong, SQL Server has some problems optimizing plans for CTEs and table variables. Using a temp table might improve the performance, but it's not a sure thing. That's why you need to test.
I'll try to find a reference to support what I'm saying here, but I'm a little busy, so it won't be immediate.