@@ -4031,7 +4031,11 @@ class DocSearch {
4031
4031
return empty_postings_list ;
4032
4032
}
4033
4033
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
+ ] ) ;
4035
4039
/**
4036
4040
* @type {Promise<[
4037
4041
* number,
@@ -4196,8 +4200,6 @@ class DocSearch {
4196
4200
} ) ) {
4197
4201
continue ;
4198
4202
}
4199
- const upla = await unpackPostingsListAll ( elem . generics , polarity ) ;
4200
- const uplb = await unpackPostingsListBindings ( elem . bindings , polarity ) ;
4201
4203
for ( const { invertedIndex : genericsIdx , queryElem : generics } of upla ) {
4202
4204
for ( const { invertedIndex : bindingsIdx , queryElem : bindings } of uplb ) {
4203
4205
results . push ( {
@@ -4303,19 +4305,23 @@ class DocSearch {
4303
4305
queryElem : new Map ( ) ,
4304
4306
} ] ;
4305
4307
}
4306
- const firstKeyIds = await index . search ( firstKey ) ;
4308
+ // HEADS UP!
4309
+ // We must put this map back the way we found it before returning,
4310
+ // otherwise things break.
4311
+ elems . delete ( firstKey ) ;
4312
+ const [ firstKeyIds , firstPostingsList , remainingAll ] = await Promise . all ( [
4313
+ index . search ( firstKey ) ,
4314
+ unpackPostingsListAll ( firstList , polarity ) ,
4315
+ unpackPostingsListBindings ( elems , polarity ) ,
4316
+ ] ) ;
4307
4317
if ( ! firstKeyIds ) {
4318
+ elems . set ( firstKey , firstList ) ;
4308
4319
// User specified a non-existent key.
4309
4320
return [ {
4310
4321
invertedIndex : empty_inverted_index ,
4311
4322
queryElem : new Map ( ) ,
4312
4323
} ] ;
4313
4324
}
4314
- elems . delete ( firstKey ) ;
4315
- const [ firstPostingsList , remainingAll ] = await Promise . all ( [
4316
- unpackPostingsListAll ( firstList , polarity ) ,
4317
- unpackPostingsListBindings ( elems , polarity ) ,
4318
- ] ) ;
4319
4325
/** @type {PostingsList<Map<number, rustdoc.QueryElement[]>>[] } */
4320
4326
const results = [ ] ;
4321
4327
for ( const keyId of firstKeyIds . matches ( ) . entries ( ) ) {
0 commit comments