refactor: Use Set for popular emojis.

This commit is contained in:
Steve Howell 2020-01-28 17:04:25 +00:00 committed by Tim Abbott
parent 345fcd3a69
commit a87798bb8e
1 changed files with 3 additions and 1 deletions

View File

@ -147,6 +147,8 @@ exports.triage = function (query, objs, get_item) {
}; };
exports.sort_emojis = function (objs, query) { exports.sort_emojis = function (objs, query) {
const popular_set = new Set(exports.popular_emojis);
const triage_results = exports.triage( const triage_results = exports.triage(
query, query,
objs, objs,
@ -157,7 +159,7 @@ exports.sort_emojis = function (objs, query) {
const other_emoji_matches = []; const other_emoji_matches = [];
for (const obj of triage_results.matches) { for (const obj of triage_results.matches) {
if (exports.popular_emojis.indexOf(obj.emoji_code) !== -1) { if (popular_set.has(obj.emoji_code)) {
popular_emoji_matches.push(obj); popular_emoji_matches.push(obj);
} else { } else {
other_emoji_matches.push(obj); other_emoji_matches.push(obj);