Skip to content

Commit 9b05c9b

Browse files
committed
rustdoc-search: improve concurrency at type search
1 parent 0becce4 commit 9b05c9b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,11 @@ class DocSearch {
40314031
return empty_postings_list;
40324032
}
40334033
const typeFilter = itemTypeFromName(elem.typeFilter);
4034-
const searchResults = await index.search(elem.normalizedPathLast);
4034+
const [searchResults, upla, uplb] = await Promise.all([
4035+
index.search(elem.normalizedPathLast),
4036+
unpackPostingsListAll(elem.generics, polarity),
4037+
unpackPostingsListBindings(elem.bindings, polarity),
4038+
]);
40354039
/**
40364040
* @type {Promise<[
40374041
* number,
@@ -4196,8 +4200,6 @@ class DocSearch {
41964200
})) {
41974201
continue;
41984202
}
4199-
const upla = await unpackPostingsListAll(elem.generics, polarity);
4200-
const uplb = await unpackPostingsListBindings(elem.bindings, polarity);
42014203
for (const {invertedIndex: genericsIdx, queryElem: generics} of upla) {
42024204
for (const {invertedIndex: bindingsIdx, queryElem: bindings} of uplb) {
42034205
results.push({
@@ -4303,19 +4305,19 @@ class DocSearch {
43034305
queryElem: new Map(),
43044306
}];
43054307
}
4306-
const firstKeyIds = await index.search(firstKey);
4308+
elems.delete(firstKey);
4309+
const [firstKeyIds, firstPostingsList, remainingAll] = await Promise.all([
4310+
index.search(firstKey),
4311+
unpackPostingsListAll(firstList, polarity),
4312+
unpackPostingsListBindings(elems, polarity),
4313+
]);
43074314
if (!firstKeyIds) {
43084315
// User specified a non-existent key.
43094316
return [{
43104317
invertedIndex: empty_inverted_index,
43114318
queryElem: new Map(),
43124319
}];
43134320
}
4314-
elems.delete(firstKey);
4315-
const [firstPostingsList, remainingAll] = await Promise.all([
4316-
unpackPostingsListAll(firstList, polarity),
4317-
unpackPostingsListBindings(elems, polarity),
4318-
]);
43194321
/** @type {PostingsList<Map<number, rustdoc.QueryElement[]>>[]} */
43204322
const results = [];
43214323
for (const keyId of firstKeyIds.matches().entries()) {

0 commit comments

Comments
 (0)