scorer: reuse hash variable

This commit is contained in:
Benjamin Pasero
2015-12-30 17:09:04 +01:00
parent 1f64a0be8d
commit 35c19d0478
+3 -2
View File
@@ -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;