You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Record the two Lua emission costs and what would remove them
Both found by reading the emitted script rather than by profiling, and both entries say
to measure first: a call count is not what the game's interpreter charges.
Every primitive array read becomes an ensureInt/ensureBool/ensureReal call, and it
survives the optimiser, so slotFor makes two Lua calls per probe step where it wants two
table indexes. The shim is needed - an untouched key is nil where Jass reads 0 or false -
but the default belongs on the table rather than at every read site. A metatable whose
__index returns the default makes a present key a raw index with no call, and runs only
on a miss, which is the rare case; three shared metatables cover the primitive types.
A method with an override stops being a direct call and becomes an instance miss plus an
__index hop. The tables are flat, so it is one hop rather than a walk, but adding an
override anywhere silently converts every call site of that slot. Class hierarchy
analysis at the call site fixes it where a slot has one reachable implementation, and
getSubMethods already holds what that needs.
0 commit comments