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.
This commit is contained in:
Steve Howell 2018-05-13 09:49:06 +00:00 committed by Tim Abbott
parent 0c9cf12933
commit b5904b264d
1 changed files with 2 additions and 2 deletions

View File

@ -313,8 +313,8 @@ exports.unread_topic_counter = (function () {
return 0; return 0;
} }
var sub = stream_data.get_sub_by_id(stream_id);
per_stream_bucketer.each(function (msgs, topic) { 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)) { if (sub && !muting.is_topic_muted(sub.name, topic)) {
stream_count += msgs.count(); stream_count += msgs.count();
} }
@ -345,8 +345,8 @@ exports.unread_topic_counter = (function () {
} }
var topic_lists = []; var topic_lists = [];
var sub = stream_data.get_sub_by_id(stream_id);
per_stream_bucketer.each(function (msgs, topic) { 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)) { if (sub && !muting.is_topic_muted(sub.name, topic)) {
topic_lists.push(msgs.members()); topic_lists.push(msgs.members());
} }