Open sprunk opened 4 weeks ago
All over Lua code that iterates over tables there's these magic -1 and -2 constants used as stack indices. E.g. https://github.com/beyond-all-reason/spring/blob/747f18b2222860ae264853aa062c5b3d9b164e25/rts/Lua/LuaSyncedRead.cpp#L2703-L2704 https://github.com/beyond-all-reason/spring/blob/747f18b2222860ae264853aa062c5b3d9b164e25/rts/Lua/LuaSyncedCtrl.cpp#L425-L426
Add (and use) some sort of named constants for them for self-documentation, e.g.
static constexpr int LUA_TABLE_VALUE_INDEX = -1; static constexpr int LUA_TABLE_KEY_INDEX = -2;
All over Lua code that iterates over tables there's these magic -1 and -2 constants used as stack indices. E.g. https://github.com/beyond-all-reason/spring/blob/747f18b2222860ae264853aa062c5b3d9b164e25/rts/Lua/LuaSyncedRead.cpp#L2703-L2704 https://github.com/beyond-all-reason/spring/blob/747f18b2222860ae264853aa062c5b3d9b164e25/rts/Lua/LuaSyncedCtrl.cpp#L425-L426
Add (and use) some sort of named constants for them for self-documentation, e.g.