@@ -811,6 +811,13 @@ function initSearch(rawSearchIndex) {
811811 return a - b ;
812812 }
813813
814+ // sort deprecated items later
815+ a = aaa . item . deprecated ;
816+ b = bbb . item . deprecated ;
817+ if ( a !== b ) {
818+ return a - b ;
819+ }
820+
814821 // sort by crate (current crate comes first)
815822 a = ( aaa . item . crate !== preferredCrate ) ;
816823 b = ( bbb . item . crate !== preferredCrate ) ;
@@ -1170,6 +1177,7 @@ function initSearch(rawSearchIndex) {
11701177 parent : item . parent ,
11711178 type : item . type ,
11721179 is_alias : true ,
1180+ deprecated : item . deprecated ,
11731181 } ;
11741182 }
11751183
@@ -1965,10 +1973,11 @@ function initSearch(rawSearchIndex) {
19651973 * n: Array<string>,
19661974 * t: Array<Number>,
19671975 * d: Array<string>,
1968- * q: Array<string>,
1976+ * q: Array<[Number, string] >,
19691977 * i: Array<Number>,
19701978 * f: Array<RawFunctionSearchType>,
19711979 * p: Array<Object>,
1980+ * c: Array<Number>
19721981 * }}
19731982 */
19741983 const crateCorpus = rawSearchIndex [ crate ] ;
@@ -1987,6 +1996,7 @@ function initSearch(rawSearchIndex) {
19871996 type : null ,
19881997 id : id ,
19891998 normalizedName : crate . indexOf ( "_" ) === - 1 ? crate : crate . replace ( / _ / g, "" ) ,
1999+ deprecated : null ,
19902000 } ;
19912001 id += 1 ;
19922002 searchIndex . push ( crateRow ) ;
@@ -1996,14 +2006,20 @@ function initSearch(rawSearchIndex) {
19962006 const itemTypes = crateCorpus . t ;
19972007 // an array of (String) item names
19982008 const itemNames = crateCorpus . n ;
1999- // an array of (String) full paths (or empty string for previous path)
2000- const itemPaths = crateCorpus . q ;
2009+ // an array of [(Number) item index,
2010+ // (String) full path]
2011+ // an item whose index is not present will fall back to the previous present path
2012+ // i.e. if indices 4 and 11 are present, but 5-10 and 12-13 are not present,
2013+ // 5-10 will fall back to the path for 4 and 12-13 will fall back to the path for 11
2014+ const itemPaths = new Map ( crateCorpus . q ) ;
20012015 // an array of (String) descriptions
20022016 const itemDescs = crateCorpus . d ;
20032017 // an array of (Number) the parent path index + 1 to `paths`, or 0 if none
20042018 const itemParentIdxs = crateCorpus . i ;
20052019 // an array of (Object | null) the type of the function, if any
20062020 const itemFunctionSearchTypes = crateCorpus . f ;
2021+ // an array of (Number) indices for the deprecated items
2022+ const deprecatedItems = new Set ( crateCorpus . c ) ;
20072023 // an array of [(Number) item type,
20082024 // (String) name]
20092025 const paths = crateCorpus . p ;
@@ -2045,12 +2061,13 @@ function initSearch(rawSearchIndex) {
20452061 crate : crate ,
20462062 ty : itemTypes [ i ] ,
20472063 name : itemNames [ i ] ,
2048- path : itemPaths [ i ] ? itemPaths [ i ] : lastPath ,
2064+ path : itemPaths . has ( i ) ? itemPaths . get ( i ) : lastPath ,
20492065 desc : itemDescs [ i ] ,
20502066 parent : itemParentIdxs [ i ] > 0 ? paths [ itemParentIdxs [ i ] - 1 ] : undefined ,
20512067 type : buildFunctionSearchType ( itemFunctionSearchTypes [ i ] , lowercasePaths ) ,
20522068 id : id ,
20532069 normalizedName : word . indexOf ( "_" ) === - 1 ? word : word . replace ( / _ / g, "" ) ,
2070+ deprecated : deprecatedItems . has ( i ) ,
20542071 } ;
20552072 id += 1 ;
20562073 searchIndex . push ( row ) ;
0 commit comments