in reply to Re^3: Turning foreach into map?
in thread Turning foreach into map?
Please be aware that the benchmark doesn't show that in this case map is faster than foreach. The fact that t_map2_r and t_map2_a are faster is that the subs don't collect the results into an array, and then return the flattened array, but return the results of the map directly. The overhead of the extra duplication of the result data is more significant than the difference between for and map.