• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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