mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
performance: Use startsWith in many places.
Using startsWith is faster than indexOf, especially for long strings and short prefixes. It's also a lot more readable. The only reason we weren't using it was when a lot of the code was originally written, it wasn't available.
This commit is contained in:
@@ -25,7 +25,7 @@ function filter_streams_by_search(streams, search_term) {
|
||||
const cands = lower_stream_name.split(" ");
|
||||
cands.push(lower_stream_name);
|
||||
return _.any(cands, function (name) {
|
||||
return name.indexOf(search_term) === 0;
|
||||
return name.startsWith(search_term);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user