mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
html search: use a `Map
` to collect file-term scores (#13060)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
70c253e968
commit
bd7d595c6b
@ -18,5 +18,8 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #13060: HTML Search: use ``Map`` to store per-file term scores.
|
||||||
|
Patch by James Addison
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
-------
|
-------
|
||||||
|
@ -547,8 +547,9 @@ const Search = {
|
|||||||
|
|
||||||
// set score for the word in each file
|
// set score for the word in each file
|
||||||
recordFiles.forEach((file) => {
|
recordFiles.forEach((file) => {
|
||||||
if (!scoreMap.has(file)) scoreMap.set(file, {});
|
if (!scoreMap.has(file)) scoreMap.set(file, new Map());
|
||||||
scoreMap.get(file)[word] = record.score;
|
const fileScores = scoreMap.get(file);
|
||||||
|
fileScores.set(word, record.score);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -587,7 +588,7 @@ const Search = {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// select one (max) score for the file.
|
// select one (max) score for the file.
|
||||||
const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
|
const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w)));
|
||||||
// add result to the result list
|
// add result to the result list
|
||||||
results.push([
|
results.push([
|
||||||
docNames[file],
|
docNames[file],
|
||||||
|
Loading…
Reference in New Issue
Block a user