@@ -2077,7 +2077,8 @@ class DocSearch {
20772077 descIndex += 1 ;
20782078 }
20792079
2080- // a String of one character item type codes
2080+ // see `RawSearchIndexCrate` in `rustdoc.d.ts` for a more
2081+ // up to date description of these fields
20812082 const itemTypes = crateCorpus . t ;
20822083 // an array of (String) item names
20832084 const itemNames = crateCorpus . n ;
@@ -2094,8 +2095,6 @@ class DocSearch {
20942095 const itemParentIdxDecoder = new VlqHexDecoder ( crateCorpus . i , noop => noop ) ;
20952096 // a map Number, string for impl disambiguators
20962097 const implDisambiguator = new Map ( crateCorpus . b ) ;
2097- // an array of [(Number) item type,
2098- // (String) name]
20992098 const rawPaths = crateCorpus . p ;
21002099 const aliases = crateCorpus . a ;
21012100 // an array of [(Number) item index,
@@ -2134,29 +2133,32 @@ class DocSearch {
21342133 // convert `rawPaths` entries into object form
21352134 // generate normalizedPaths for function search mode
21362135 let len = rawPaths . length ;
2137- let lastPath = itemPaths . get ( 0 ) ;
2136+ const lastPathU = itemPaths . get ( 0 ) ;
2137+ let lastPath = lastPathU === undefined ? null : lastPathU ;
21382138 for ( let i = 0 ; i < len ; ++ i ) {
21392139 const elem = rawPaths [ i ] ;
21402140 const ty = elem [ 0 ] ;
21412141 const name = elem [ 1 ] ;
2142- let path = null ;
2143- if ( elem . length > 2 && elem [ 2 ] !== null ) {
2144- path = itemPaths . has ( elem [ 2 ] ) ? itemPaths . get ( elem [ 2 ] ) : lastPath ;
2145- lastPath = path ;
2146- }
2147- let exactPath = elem . length > 3 && elem [ 3 ] !== null ?
2148- // @ts -expect-error
2149- itemPaths . get ( elem [ 3 ] ) :
2150- path ;
2142+ /**
2143+ * @param {2|3 } idx
2144+ * @param {string|null } if_null
2145+ * @param {string|null } if_not_found
2146+ * @returns {string|null }
2147+ */
2148+ const elemPath = ( idx , if_null , if_not_found ) => {
2149+ if ( elem . length > idx && elem [ idx ] !== undefined ) {
2150+ const p = itemPaths . get ( elem [ idx ] ) ;
2151+ if ( p !== undefined ) {
2152+ return p ;
2153+ }
2154+ return if_not_found ;
2155+ }
2156+ return if_null ;
2157+ } ;
2158+ const path = elemPath ( 2 , lastPath , null ) ;
2159+ const exactPath = elemPath ( 3 , path , path ) ;
21512160 const unboxFlag = elem . length > 4 && ! ! elem [ 4 ] ;
21522161
2153- if ( path === undefined ) {
2154- path = null ;
2155- }
2156- if ( exactPath === undefined ) {
2157- exactPath = null ;
2158- }
2159-
21602162 lowercasePaths . push ( { ty, name : name . toLowerCase ( ) , path, exactPath, unboxFlag } ) ;
21612163 paths [ i ] = { ty, name, path, exactPath, unboxFlag } ;
21622164 }
0 commit comments