Changeset

8092:0a1c0f1107d2

util.datamanager: Use already known index instead of measuring length each iteration
author Kim Alvefur <zash@zash.se>
date Mon, 17 Apr 2017 03:26:21 +0200
parents 8089:4ba8cb75d925
children 8094:dcda2ae4569d
files util/datamanager.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/datamanager.lua	Sat Apr 15 02:27:07 2017 +0200
+++ b/util/datamanager.lua	Mon Apr 17 03:26:21 2017 +0200
@@ -268,8 +268,8 @@
 	if callback(username, host, datastore) == false then return true; end
 	-- save the datastore
 	local d = {};
-	for _, item in ipairs(data) do
-		d[#d+1] = "item(" .. serialize(item) .. ");\n";
+	for i, item in ipairs(data) do
+		d[i] = "item(" .. serialize(item) .. ");\n";
 	end
 	local ok, msg = atomic_store(getpath(username, host, datastore, "list", true), t_concat(d));
 	if not ok then