diff options
author | Kim Alvefur <zash@zash.se> | 2017-11-10 09:44:30 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-11-10 09:44:30 +0100 |
commit | 38e1fc8dae06a7b164f62bccfdc7dcdb69b5256b (patch) | |
tree | cb5e7b4e95c3558d3aee6be811f9a6494045326f | |
parent | b242e3d0daf88b0f28205ac7152b02cdb9ef2193 (diff) | |
download | prosody-38e1fc8dae06a7b164f62bccfdc7dcdb69b5256b.tar.gz prosody-38e1fc8dae06a7b164f62bccfdc7dcdb69b5256b.zip |
mod_storage_internal: Optimize truncation
-rw-r--r-- | plugins/mod_storage_internal.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index 55a4bfeb..4395c3f0 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -195,14 +195,15 @@ function archive:delete(username, query) if query.reverse then -- Before: { 1, 2, 3, 4, 5, } -- After: { 1, 2, 3 } - while #items > query.truncate do - table.remove(items); + for i = #items, query.truncate + 1, -1 do + items[i] = nil; end else -- Before: { 1, 2, 3, 4, 5, } -- After: { 3, 4, 5 } - while #items > query.truncate do - table.remove(items, 1); + local offset = #items - query.truncate; + for i = 1, #items do + items[i] = items[i+offset]; end end end |