"Localizing" functions and constants.

"Localizing" functions and constants.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
dizekat
Posts: 438
Joined: 07 Dec 2007, 12:10

"Localizing" functions and constants.

Post by dizekat »

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.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: "Localizing" functions and constants.

Post by Kloot »

viewtopic.php?f=21&t=15748

Lua scripts are not JIT'ed.
dizekat
Posts: 438
Joined: 07 Dec 2007, 12:10

Re: "Localizing" functions and constants.

Post by dizekat »

What was the problem using luajit in spring?
luajit features
looks good... is there any unsupported important lua features now?
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: "Localizing" functions and constants.

Post by very_bad_soldier »

I find this quite interesting: http://trac.caspring.org/wiki/LuaPerformance
Post Reply

Return to “Lua Scripts”