mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Use a local table reference to prevent re-alloc
This commit is contained in:
parent
65b9e6d547
commit
9fc7179981
@ -71,6 +71,11 @@ local settings_type = {
|
|||||||
|
|
||||||
local settings = {}
|
local settings = {}
|
||||||
local memory = {}
|
local memory = {}
|
||||||
|
local raw_callback_setting = {
|
||||||
|
callback = function (input)
|
||||||
|
return true, input
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
Global.register(memory, function (tbl) memory = tbl end)
|
Global.register(memory, function (tbl) memory = tbl end)
|
||||||
|
|
||||||
@ -158,11 +163,7 @@ end
|
|||||||
function Public.set(player_index, name, value)
|
function Public.set(player_index, name, value)
|
||||||
local setting = settings[name]
|
local setting = settings[name]
|
||||||
if not setting then
|
if not setting then
|
||||||
setting = {
|
setting = raw_callback_setting
|
||||||
callback = function (input)
|
|
||||||
return true, input
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local success, sanitized_value = setting.callback(value)
|
local success, sanitized_value = setting.callback(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user