# HG changeset patch # User Kim Alvefur # Date 1510303470 -3600 # Node ID 4892c22403d5fe8c1ca2fd524ae0ee58cb51765a # Parent b6a7b83f8d87e0420f455fbd1e024fa3eb8964c9 mod_storage_internal: Optimize truncation diff -r b6a7b83f8d87 -r 4892c22403d5 plugins/mod_storage_internal.lua --- 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