From b5904b264d6e14cde3b4784adb0123d75310143e Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sun, 13 May 2018 09:49:06 +0000 Subject: [PATCH] minor: Pull statements out of loops in unread.js. We were recalculating the same sub for every iteration in these two loops. It's a pretty fast operation but still nice to do only one time. --- static/js/unread.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/unread.js b/static/js/unread.js index cc4af372ab..da47f838c3 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -313,8 +313,8 @@ exports.unread_topic_counter = (function () { return 0; } + var sub = stream_data.get_sub_by_id(stream_id); per_stream_bucketer.each(function (msgs, topic) { - var sub = stream_data.get_sub_by_id(stream_id); if (sub && !muting.is_topic_muted(sub.name, topic)) { stream_count += msgs.count(); } @@ -345,8 +345,8 @@ exports.unread_topic_counter = (function () { } var topic_lists = []; + var sub = stream_data.get_sub_by_id(stream_id); per_stream_bucketer.each(function (msgs, topic) { - var sub = stream_data.get_sub_by_id(stream_id); if (sub && !muting.is_topic_muted(sub.name, topic)) { topic_lists.push(msgs.members()); }