提交 35c19d04 编写于 作者: B Benjamin Pasero

scorer: reuse hash variable

上级 1f64a0be
......@@ -37,7 +37,8 @@ export function score(target: string, query: string, cache?: {[id: string]: numb
return 0; // return early if target or query are undefined
}
const cached = cache && cache[target + query];
const hash = target + query;
const cached = cache && cache[hash];
if (typeof cached === 'number') {
return cached;
}
......@@ -85,7 +86,7 @@ export function score(target: string, query: string, cache?: {[id: string]: numb
}
if (cache) {
cache[target + query] = score;
cache[hash] = score;
}
return score;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册