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

View File

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