diff options
| author | binarycat <binarycat@envs.net> | 2025-03-24 16:19:05 -0500 |
|---|---|---|
| committer | binarycat <binarycat@envs.net> | 2025-03-24 16:19:05 -0500 |
| commit | ccd95ac7fde43d6a0380895086efca3a75e1ac35 (patch) | |
| tree | f9913fafdf356bb92858a5b8dbf12a1eab6bbb72 | |
| parent | c123adf860b008f703b325d013e7c7c0cc707d56 (diff) | |
| download | rust-ccd95ac7fde43d6a0380895086efca3a75e1ac35.tar.gz rust-ccd95ac7fde43d6a0380895086efca3a75e1ac35.zip | |
search.js: improve typechecking by avoiding Map.has
| -rw-r--r-- | src/librustdoc/html/static/js/search.js | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index decb4807e88..a8c6193a4c1 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1310,10 +1310,9 @@ class NameTrie { let sste; if (substart >= 2) { const tail = name.substring(substart - 2, substart + 1); - if (tailTable.has(tail)) { - // it's not undefined - // @ts-expect-error - sste = tailTable.get(tail); + const entry = tailTable.get(tail); + if (entry !== undefined) { + sste = entry; } else { sste = []; tailTable.set(tail, sste); @@ -1337,10 +1336,9 @@ class NameTrie { new Lev1TParametricDescription(name.length); this.searchLev(name, 0, levParams, results); const tail = name.substring(0, 3); - if (tailTable.has(tail)) { - // it's not undefined - // @ts-expect-error - for (const entry of tailTable.get(tail)) { + const list = tailTable.get(tail); + if (list !== undefined) { + for (const entry of list) { entry.searchSubstringPrefix(name, 3, results); } } @@ -1599,10 +1597,8 @@ class DocSearch { return null; } - if (this.typeNameIdMap.has(name)) { - /** @type {{id: number, assocOnly: boolean}} */ - // @ts-expect-error - const obj = this.typeNameIdMap.get(name); + const obj = this.typeNameIdMap.get(name); + if (obj !== undefined) { obj.assocOnly = !!(isAssocType && obj.assocOnly); return obj.id; } else { @@ -2145,7 +2141,6 @@ class DocSearch { const name = elem[1]; let path = null; if (elem.length > 2 && elem[2] !== null) { - // @ts-expect-error path = itemPaths.has(elem[2]) ? itemPaths.get(elem[2]) : lastPath; lastPath = path; } |
