Software /
code /
prosody
Comparison
util/datamanager.lua @ 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 |
parent | 8014:ff3787033abb |
child | 8299:756a2a00e7e7 |
comparison
equal
deleted
inserted
replaced
8089:4ba8cb75d925 | 8092:0a1c0f1107d2 |
---|---|
266 data = {}; | 266 data = {}; |
267 end | 267 end |
268 if callback(username, host, datastore) == false then return true; end | 268 if callback(username, host, datastore) == false then return true; end |
269 -- save the datastore | 269 -- save the datastore |
270 local d = {}; | 270 local d = {}; |
271 for _, item in ipairs(data) do | 271 for i, item in ipairs(data) do |
272 d[#d+1] = "item(" .. serialize(item) .. ");\n"; | 272 d[i] = "item(" .. serialize(item) .. ");\n"; |
273 end | 273 end |
274 local ok, msg = atomic_store(getpath(username, host, datastore, "list", true), t_concat(d)); | 274 local ok, msg = atomic_store(getpath(username, host, datastore, "list", true), t_concat(d)); |
275 if not ok then | 275 if not ok then |
276 log("error", "Unable to write to %s storage ('%s') for user: %s@%s", datastore, msg, username or "nil", host or "nil"); | 276 log("error", "Unable to write to %s storage ('%s') for user: %s@%s", datastore, msg, username or "nil", host or "nil"); |
277 return; | 277 return; |