streams: Add LazySet for subscribers.

This defers O(N*S) operations, where

    N = number of streams
    S = number of subscribers per stream

In many cases we never do an O(N) operation on
a stream.  Exceptions include:

    - checking stream links from the compose box
    - editing a stream
    - adding members to a newly added stream

An operation that used to be O(N)--computing
the number of subscribers--is now O(1), and we
don't even pay O(N) on a one-time basis to
compute it (not counting the cost to build the
array from JSON, but we have to do that).
This commit is contained in:
Steve Howell
2019-12-27 12:16:22 +00:00
committed by Tim Abbott
parent e804f39f0e
commit a3512553a8
6 changed files with 85 additions and 17 deletions

View File

@@ -36,12 +36,9 @@ exports.is_sub_settings_active = function (sub) {
};
exports.get_email_of_subscribers = function (subscribers) {
const emails = [];
subscribers.each(function (o, i) {
const email = people.get_person_from_user_id(i).email;
emails.push(email);
return subscribers.map(function (user_id) {
return people.get_person_from_user_id(user_id).email;
});
return emails;
};
function clear_edit_panel() {