"Localizing" functions and constants.
Posted: 06 Aug 2008, 13:00
I see a lot of widgets define local aliases for all the spring commands and constants that them use.
Did anyone ever benchmark properly if that makes anything faster?
Spring is using LUA JIT, aka "just in time compiler" (edit: or, at very least, compiles into VM), and i suppose compiler would look up all symbols only on first use anyway (no dictionary searches on consequent symbol uses), so that you gain precisely nothing from defining local names; only get slightly slower loading time and more obfuscation.
Speed advantage from defining local aliases seems really dubious and unlikely; and if it does give any advantage, i'd rather fix JIT compiler than obfuscate all the lua code i write.
Did anyone ever benchmark properly if that makes anything faster?
Spring is using LUA JIT, aka "just in time compiler" (edit: or, at very least, compiles into VM), and i suppose compiler would look up all symbols only on first use anyway (no dictionary searches on consequent symbol uses), so that you gain precisely nothing from defining local names; only get slightly slower loading time and more obfuscation.
Speed advantage from defining local aliases seems really dubious and unlikely; and if it does give any advantage, i'd rather fix JIT compiler than obfuscate all the lua code i write.