Diff

util/queue.lua @ 9902:3eea63a68e0f

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.
author Matthew Wild <mwild1@gmail.com>
date Sat, 23 Mar 2019 08:52:57 +0000
parent 9901:c8b75239846c
child 9925:8d0112413997
line wrap: on
line diff
--- a/util/queue.lua	Sat Mar 23 08:47:55 2019 +0000
+++ b/util/queue.lua	Sat Mar 23 08:52:57 2019 +0000
@@ -52,16 +52,15 @@
 			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)