@@ -2077,7 +2077,8 @@ class DocSearch {
2077
2077
descIndex += 1 ;
2078
2078
}
2079
2079
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
2081
2082
const itemTypes = crateCorpus . t ;
2082
2083
// an array of (String) item names
2083
2084
const itemNames = crateCorpus . n ;
@@ -2094,8 +2095,6 @@ class DocSearch {
2094
2095
const itemParentIdxDecoder = new VlqHexDecoder ( crateCorpus . i , noop => noop ) ;
2095
2096
// a map Number, string for impl disambiguators
2096
2097
const implDisambiguator = new Map ( crateCorpus . b ) ;
2097
- // an array of [(Number) item type,
2098
- // (String) name]
2099
2098
const rawPaths = crateCorpus . p ;
2100
2099
const aliases = crateCorpus . a ;
2101
2100
// an array of [(Number) item index,
@@ -2134,29 +2133,32 @@ class DocSearch {
2134
2133
// convert `rawPaths` entries into object form
2135
2134
// generate normalizedPaths for function search mode
2136
2135
let len = rawPaths . length ;
2137
- let lastPath = itemPaths . get ( 0 ) ;
2136
+ const lastPathU = itemPaths . get ( 0 ) ;
2137
+ let lastPath = lastPathU === undefined ? null : lastPathU ;
2138
2138
for ( let i = 0 ; i < len ; ++ i ) {
2139
2139
const elem = rawPaths [ i ] ;
2140
2140
const ty = elem [ 0 ] ;
2141
2141
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 ) ;
2151
2160
const unboxFlag = elem . length > 4 && ! ! elem [ 4 ] ;
2152
2161
2153
- if ( path === undefined ) {
2154
- path = null ;
2155
- }
2156
- if ( exactPath === undefined ) {
2157
- exactPath = null ;
2158
- }
2159
-
2160
2162
lowercasePaths . push ( { ty, name : name . toLowerCase ( ) , path, exactPath, unboxFlag } ) ;
2161
2163
paths [ i ] = { ty, name, path, exactPath, unboxFlag } ;
2162
2164
}
0 commit comments