comparison plugins/muc/history.lib.lua @ 11711:6fbbfa4a1178

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.
author Kim Alvefur <zash@zash.se>
date Mon, 19 Jul 2021 17:07:59 +0200
parents ab820b2ad199
children 74b9e05af71e
comparison
equal deleted inserted replaced
11710:26a8cc9d9eb7 11711:6fbbfa4a1178
171 end, 50); -- Before subject(20) 171 end, 50); -- Before subject(20)
172 172
173 -- add to history 173 -- add to history
174 module:hook("muc-add-history", function(event) 174 module:hook("muc-add-history", function(event)
175 local room = event.room 175 local room = event.room
176 if get_historylength(room) == 0 then
177 room._history = nil;
178 return;
179 end
176 local history = room._history; 180 local history = room._history;
177 if not history then history = {}; room._history = history; end 181 if not history then history = {}; room._history = history; end
178 local stanza = st.clone(event.stanza); 182 local stanza = st.clone(event.stanza);
179 stanza.attr.to = ""; 183 stanza.attr.to = "";
180 local ts = gettime(); 184 local ts = gettime();