Don't mark meta private when deleting them

This is a small optimization that may reduce the tendency to
mark blocks as dirty, especially due to soaking ABMs that may
clear meta fields more widely.
This commit is contained in:
Aaron Suen 2024-09-25 19:33:46 -04:00
parent d63ce33ad7
commit 3d660e40f1

View File

@ -19,11 +19,11 @@ nodecore.public_meta_fields = publicfields
local function hook(meta) local function hook(meta)
for k, v in pairs(meta) do for k, v in pairs(meta) do
if k:sub(1, 4) == "set_" then if k:sub(1, 4) == "set_" then
meta[k] = function(data, name, ...) meta[k] = function(data, name, val, ...)
if not publicfields[name] then if val ~= "" and not publicfields[name] then
data:mark_as_private(name) data:mark_as_private(name)
end end
return v(data, name, ...) return v(data, name, val, ...)
end end
nodecore.log("info", modname .. " auto-privatized meta " .. k) nodecore.log("info", modname .. " auto-privatized meta " .. k)
end end