Software /
code /
prosody
Diff
plugins/mod_storage_internal.lua @ 8394:4892c22403d5
mod_storage_internal: Optimize truncation
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 10 Nov 2017 09:44:30 +0100 |
parent | 8393:b6a7b83f8d87 |
child | 8402:469afa02947b |
line wrap: on
line diff
--- a/plugins/mod_storage_internal.lua Thu Nov 09 01:42:01 2017 +0100 +++ b/plugins/mod_storage_internal.lua Fri Nov 10 09:44:30 2017 +0100 @@ -195,14 +195,15 @@ 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