From 0698511eab7ee0aef0d5ec677cf009b7ec8c3844 Mon Sep 17 00:00:00 2001 From: Pinky Snow Date: Mon, 21 Dec 2015 23:28:40 -0500 Subject: [PATCH 1/2] speed up saving of homefile switched to table.concat() and only use output:write() one time for speed --- mods/sethome/init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mods/sethome/init.lua b/mods/sethome/init.lua index 590086b4..b7128ce7 100644 --- a/mods/sethome/init.lua +++ b/mods/sethome/init.lua @@ -54,11 +54,13 @@ minetest.register_chatcommand("sethome", { minetest.chat_send_player(name, "Home set!") changed = true if changed then - local output = io.open(homes_file, "w") - for i, v in pairs(homepos) do - output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n") - end - io.close(output) + local output = io.open(home_file, "w") + local data = {} + for n, p in pairs(homepos) do + table.insert(data,(p.x.." "..p.y.." "..p.z.." "..n.."\n") + end + output:write(table.concat(data)) + io.close(output) changed = false end end, From 4eacc2c2f37f02819515dd853cb3d6b3385cf72b Mon Sep 17 00:00:00 2001 From: Pinky Snow Date: Tue, 22 Dec 2015 03:27:23 -0500 Subject: [PATCH 2/2] Update init.lua --- mods/sethome/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/sethome/init.lua b/mods/sethome/init.lua index b7128ce7..50d0793f 100644 --- a/mods/sethome/init.lua +++ b/mods/sethome/init.lua @@ -57,7 +57,7 @@ minetest.register_chatcommand("sethome", { local output = io.open(home_file, "w") local data = {} for n, p in pairs(homepos) do - table.insert(data,(p.x.." "..p.y.." "..p.z.." "..n.."\n") + table.insert(data,(p.x.." "..p.y.." "..p.z.." "..n.."\n")) end output:write(table.concat(data)) io.close(output)