@@ -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,23 @@ class DocSearch {
43034305 queryElem : new Map ( ) ,
43044306 } ] ;
43054307 }
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+ ] ) ;
43074317 if ( ! firstKeyIds ) {
4318+ elems . set ( firstKey , firstList ) ;
43084319 // User specified a non-existent key.
43094320 return [ {
43104321 invertedIndex : empty_inverted_index ,
43114322 queryElem : new Map ( ) ,
43124323 } ] ;
43134324 }
4314- elems . delete ( firstKey ) ;
4315- const [ firstPostingsList , remainingAll ] = await Promise . all ( [
4316- unpackPostingsListAll ( firstList , polarity ) ,
4317- unpackPostingsListBindings ( elems , polarity ) ,
4318- ] ) ;
43194325 /** @type {PostingsList<Map<number, rustdoc.QueryElement[]>>[] } */
43204326 const results = [ ] ;
43214327 for ( const keyId of firstKeyIds . matches ( ) . entries ( ) ) {
0 commit comments