From ca6757f326a5f17ae4a8ba0bfe54568e6c81ca83 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sat, 27 Feb 2021 17:16:30 +0100 Subject: [PATCH] table: get rid of unneeded metatable duplication --- table.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/table.lua b/table.lua index 647c14f..fb07aef 100644 --- a/table.lua +++ b/table.lua @@ -1,14 +1,15 @@ -- Table helpers function map_index(table, func) - return setmetatable(table, { + local mapping_metatable = { __index = function(table, key) return rawget(table, func(key)) end, __newindex = function(table, key, value) rawset(table, func(key), value) end - }) + } + return setmetatable(table, mapping_metatable) end function set_case_insensitive_index(table)