mod_mam: Use for loop in metadata query
authorKim Alvefur <zash@zash.se>
Sun, 26 Nov 2023 22:58:11 +0100
changeset 13361 f424c9f1460b
parent 13360 bbbda8819331
child 13362 2b8ec22988af
mod_mam: Use for loop in metadata query Some storage drivers will perform cleanup after the last iteration, but if only one step is taken this might be delayed until the garbage collector gets to it.
plugins/mod_mam/mod_mam.lua
--- a/plugins/mod_mam/mod_mam.lua	Wed Nov 29 17:51:34 2023 +0000
+++ b/plugins/mod_mam/mod_mam.lua	Sun Nov 26 22:58:11 2023 +0100
@@ -249,8 +249,7 @@
 			return true;
 		end
 
-		local id, _, when = first();
-		if id then
+		for id, _, when in first do
 			reply:tag("start", { id = id, timestamp = timestamp(when) }):up();
 		end
 	end
@@ -262,8 +261,7 @@
 			return true;
 		end
 
-		local id, _, when = last();
-		if id then
+		for id, _, when in last do
 			reply:tag("end", { id = id, timestamp = timestamp(when) }):up();
 		end
 	end