aboutsummaryrefslogtreecommitdiffstats
path: root/util/queue.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2019-03-26 13:54:14 +0000
committerMatthew Wild <mwild1@gmail.com>2019-03-26 13:54:14 +0000
commite5d74b77aec0f9c63104384ef1f550d57959fbce (patch)
tree59efb3afc5e804923a3b683d7543461af6c14e63 /util/queue.lua
parentde724221378ba5772c9cfdb2d40c43619da8166f (diff)
downloadprosody-e5d74b77aec0f9c63104384ef1f550d57959fbce.tar.gz
prosody-e5d74b77aec0f9c63104384ef1f550d57959fbce.zip
util.queue: Update :items() to consistently use private data directly
It will perform better this way, and we were accessing private variables already within the iterator. Replaces 3eea63a68e0f
Diffstat (limited to 'util/queue.lua')
-rw-r--r--util/queue.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/util/queue.lua b/util/queue.lua
index e63b3f1c..66ed098b 100644
--- a/util/queue.lua
+++ b/util/queue.lua
@@ -52,16 +52,15 @@ local function new(size, allow_wrapping)
return t[tail];
end;
items = function (self)
- --luacheck: ignore 431/t
- return function (t, pos)
- if pos >= t:count() then
+ return function (_, pos)
+ if pos >= items then
return nil;
end
local read_pos = tail + pos;
- if read_pos > t.size then
+ if read_pos > self.size then
read_pos = (read_pos%size);
end
- return pos+1, t._items[read_pos];
+ return pos+1, t[read_pos];
end, self, 0;
end;
consume = function (self)