# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1626707279 -7200
# Node ID 6fbbfa4a1178282d08b453d941da0946c0e8f7ae
# Parent  26a8cc9d9eb7ac178558f99c69be904c0227628e
MUC: Skip adding to history when it's set to zero

Optimizes away all the processing on every message in case the
end-result is zero history.

diff -r 26a8cc9d9eb7 -r 6fbbfa4a1178 plugins/muc/history.lib.lua
--- a/plugins/muc/history.lib.lua	Sun Jul 18 23:25:45 2021 +0200
+++ b/plugins/muc/history.lib.lua	Mon Jul 19 17:07:59 2021 +0200
@@ -173,6 +173,10 @@
 -- add to history
 module:hook("muc-add-history", function(event)
 	local room = event.room
+	if get_historylength(room) == 0 then
+		room._history = nil;
+		return;
+	end
 	local history = room._history;
 	if not history then history = {}; room._history = history; end
 	local stanza = st.clone(event.stanza);