1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2025-07-05 09:30:32 +02:00

Remove unused variables and assignments

The removal of unused variables can improve the detection of mistakes with luacheck;
for example, it can detect if the wrong argument is passed to a function because of a copy-paste mistake.

Setting `src_data` and `dst_data` to `nil` in `worldedit.stack2`,
which might enable an earlier garbage collection,
looks like an unneeded micro-optimisation.
This commit is contained in:
HybridDog
2021-01-17 16:59:29 +01:00
parent bf55f52197
commit 0632f6b41b
5 changed files with 7 additions and 12 deletions

View File

@ -217,8 +217,6 @@ function worldedit.copy2(pos1, pos2, off, meta_backwards)
dst_manip:set_param2_data(dst_data)
mh.finish(dst_manip)
src_data = nil
dst_data = nil
-- Copy metadata
local get_meta = minetest.get_meta

View File

@ -160,7 +160,7 @@ end
--- Loads the schematic in `value` into a node list in the latest format.
-- @return A node list in the latest format, or nil on failure.
local function load_schematic(value)
local version, header, content = worldedit.read_header(value)
local version, _, content = worldedit.read_header(value)
local nodes = {}
if version == 1 or version == 2 then -- Original flat table format
local tables = minetest.deserialize(content, true)
@ -250,7 +250,6 @@ function worldedit.deserialize(origin_pos, value)
worldedit.keep_loaded(pos1, pos2)
local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z
local count = 0
local add_node, get_meta = minetest.add_node, minetest.get_meta
for i, entry in ipairs(nodes) do
entry.x, entry.y, entry.z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z