util.queue: Update :items() to consistently use private data directly
authorMatthew Wild <mwild1@gmail.com>
Tue, 26 Mar 2019 13:54:14 +0000
changeset 9930 1bfd28e774db
parent 9929 8d0112413997
child 9931 1460c4966262
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
util/queue.lua
--- a/util/queue.lua	Tue Mar 26 13:51:06 2019 +0000
+++ b/util/queue.lua	Tue Mar 26 13:54:14 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)