search_suggestion: Convert prev from object to Set.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-02-11 22:06:56 -08:00 committed by Tim Abbott
parent e848bc2a21
commit bf0a3d9d14
1 changed files with 3 additions and 3 deletions

View File

@ -582,7 +582,7 @@ function get_operator_suggestions(last) {
function make_attacher(base) {
const self = {};
self.result = [];
const prev = {};
const prev = new Set();
function prepend_base(suggestion) {
if (base && base.description.length > 0) {
@ -592,8 +592,8 @@ function make_attacher(base) {
}
self.push = function (suggestion) {
if (!prev[suggestion.search_string]) {
prev[suggestion.search_string] = suggestion;
if (!prev.has(suggestion.search_string)) {
prev.add(suggestion.search_string);
self.result.push(suggestion);
}
};