diff --git a/lua/entities/gmod_wire_expression2/core/selfaware.lua b/lua/entities/gmod_wire_expression2/core/selfaware.lua index 47b9d113f1..5b5d7bdb0b 100644 --- a/lua/entities/gmod_wire_expression2/core/selfaware.lua +++ b/lua/entities/gmod_wire_expression2/core/selfaware.lua @@ -206,26 +206,29 @@ end --[[******************************************************************************]]-- -- Extensions +local getExtensionStatus = E2Lib.GetExtensionStatus +local e2Extensions +local e2ExtensionsTable +-- See postinit for these getting initialized + [nodiscard] e2function array getExtensions() - return table.Copy(E2Lib.GetExtensions()) + local ret = {} + for k, v in ipairs(e2Extensions) do -- Optimized shallow copy + ret[k] = v + end + return ret end -local getExtensionStatus = E2Lib.GetExtensionStatus +__e2setcost(10) + [nodiscard] e2function table getExtensionStatus() - local ret = E2Lib.newE2Table() - local s, stypes, size = ret.s, ret.stypes, ret.size - for _, ext in ipairs(E2Lib.GetExtensions()) do - s[ext] = getExtensionStatus(ext) and 1 or 0 - stypes[ext] = "n" - size = size + 1 - end - ret.s, ret.stypes, ret.size = s, stypes, size -- Do this just because I'm paranoid - - return ret + return table.Copy(e2ExtensionsTable) end +__e2setcost(5) + [nodiscard] e2function number getExtensionStatus(string extension) return getExtensionStatus(extension) and 1 or 0 @@ -315,6 +318,18 @@ registerCallback("postinit", function() end end end + + e2Extensions = E2Lib.GetExtensions() + e2ExtensionsTable = E2Lib.newE2Table() + do + local s, stypes, size = e2ExtensionsTable.s, e2ExtensionsTable.stypes, 0 + for _, ext in ipairs(e2Extensions) do + s[ext] = getExtensionStatus(ext) and 1 or 0 + stypes[ext] = "n" + size = size + 1 + end + e2ExtensionsTable.size = size + end end) --[[******************************************************************************]]--