• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Lua] [Deprecated] __jarray Compactor (GUI helper)

This small snippet will cut the number of tables produced by __jarray almost by 50%. The regular __jarray function currently produces two tables per initialization due to the setmetatable call, however this will instead cache the metatables with the same default return value and recycle them.

Lua:
do --__jarray compactor 1.0 by Bribe
    local mts = {}
    function __jarray(default)
        if default then
            local mt = mts[default]
            if not mt then
                mt = {__index = function() return default end}
                mts[default] = mt
            end
            return setmetatable({}, mt)
        end
        return {}
    end
end
 
Top