@@ -881,6 +881,13 @@ function initSearch(rawSearchIndex) {
881881 return a - b ;
882882 }
883883
884+ // sort deprecated items later
885+ a = aaa . item . deprecated ;
886+ b = bbb . item . deprecated ;
887+ if ( a !== b ) {
888+ return a - b ;
889+ }
890+
884891 // sort by crate (current crate comes first)
885892 a = ( aaa . item . crate !== preferredCrate ) ;
886893 b = ( bbb . item . crate !== preferredCrate ) ;
@@ -1244,6 +1251,7 @@ function initSearch(rawSearchIndex) {
12441251 parent : item . parent ,
12451252 type : item . type ,
12461253 is_alias : true ,
1254+ deprecated : item . deprecated ,
12471255 } ;
12481256 }
12491257
@@ -2064,10 +2072,11 @@ function initSearch(rawSearchIndex) {
20642072 * n: Array<string>,
20652073 * t: String,
20662074 * d: Array<string>,
2067- * q: Array<string>,
2075+ * q: Array<[Number, string] >,
20682076 * i: Array<Number>,
20692077 * f: Array<RawFunctionSearchType>,
20702078 * p: Array<Object>,
2079+ * c: Array<Number>
20712080 * }}
20722081 */
20732082 const crateCorpus = rawSearchIndex [ crate ] ;
@@ -2086,6 +2095,7 @@ function initSearch(rawSearchIndex) {
20862095 type : null ,
20872096 id : id ,
20882097 normalizedName : crate . indexOf ( "_" ) === - 1 ? crate : crate . replace ( / _ / g, "" ) ,
2098+ deprecated : null ,
20892099 } ;
20902100 id += 1 ;
20912101 searchIndex . push ( crateRow ) ;
@@ -2095,14 +2105,20 @@ function initSearch(rawSearchIndex) {
20952105 const itemTypes = crateCorpus . t ;
20962106 // an array of (String) item names
20972107 const itemNames = crateCorpus . n ;
2098- // an array of (String) full paths (or empty string for previous path)
2099- const itemPaths = crateCorpus . q ;
2108+ // an array of [(Number) item index,
2109+ // (String) full path]
2110+ // an item whose index is not present will fall back to the previous present path
2111+ // i.e. if indices 4 and 11 are present, but 5-10 and 12-13 are not present,
2112+ // 5-10 will fall back to the path for 4 and 12-13 will fall back to the path for 11
2113+ const itemPaths = new Map ( crateCorpus . q ) ;
21002114 // an array of (String) descriptions
21012115 const itemDescs = crateCorpus . d ;
21022116 // an array of (Number) the parent path index + 1 to `paths`, or 0 if none
21032117 const itemParentIdxs = crateCorpus . i ;
21042118 // an array of (Object | null) the type of the function, if any
21052119 const itemFunctionSearchTypes = crateCorpus . f ;
2120+ // an array of (Number) indices for the deprecated items
2121+ const deprecatedItems = new Set ( crateCorpus . c ) ;
21062122 // an array of [(Number) item type,
21072123 // (String) name]
21082124 const paths = crateCorpus . p ;
@@ -2142,12 +2158,13 @@ function initSearch(rawSearchIndex) {
21422158 crate : crate ,
21432159 ty : itemTypes . charCodeAt ( i ) - charA ,
21442160 name : itemNames [ i ] ,
2145- path : itemPaths [ i ] ? itemPaths [ i ] : lastPath ,
2161+ path : itemPaths . has ( i ) ? itemPaths . get ( i ) : lastPath ,
21462162 desc : itemDescs [ i ] ,
21472163 parent : itemParentIdxs [ i ] > 0 ? paths [ itemParentIdxs [ i ] - 1 ] : undefined ,
21482164 type : buildFunctionSearchType ( itemFunctionSearchTypes [ i ] , lowercasePaths ) ,
21492165 id : id ,
21502166 normalizedName : word . indexOf ( "_" ) === - 1 ? word : word . replace ( / _ / g, "" ) ,
2167+ deprecated : deprecatedItems . has ( i ) ,
21512168 } ;
21522169 id += 1 ;
21532170 searchIndex . push ( row ) ;
0 commit comments