|Just another Perl shrine|
Ampersands and sub speedby creamygoodness (Curate)
|on Oct 14, 2005 at 20:58 UTC||Need Help??|
I was running some benchmarks to see how much of a penalty you incur when calling a sub as a method as opposed to a function, and I came across something unexpected: prepending a function name with an ampersand makes the call faster.
I suppose this is because the ampersand identifies the token as a function name, and so Perl doesn't have to spend any time disambiguating it -- but I'm surprised that that seems to be happening on the fly, at run-time.
Guess I'll be lubricating a few bottlenecks with ampersands...
Rectangular Research ― http://www.rectangular.com