Yes, it will. In fact you can cut down on the amount of useless processing further by replacing all those
returns with
return map [$_], @_ if $n == 1;
and then you have the equivalent to the code I wrote, except passing around full lists rather than just an arrayref.
Makeshifts last the longest.