@@ -811,6 +811,13 @@ function initSearch(rawSearchIndex) {
811
811
return a - b ;
812
812
}
813
813
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
+
814
821
// sort by crate (current crate comes first)
815
822
a = ( aaa . item . crate !== preferredCrate ) ;
816
823
b = ( bbb . item . crate !== preferredCrate ) ;
@@ -1170,6 +1177,7 @@ function initSearch(rawSearchIndex) {
1170
1177
parent : item . parent ,
1171
1178
type : item . type ,
1172
1179
is_alias : true ,
1180
+ deprecated : item . deprecated ,
1173
1181
} ;
1174
1182
}
1175
1183
@@ -1965,10 +1973,11 @@ function initSearch(rawSearchIndex) {
1965
1973
* n: Array<string>,
1966
1974
* t: Array<Number>,
1967
1975
* d: Array<string>,
1968
- * q: Array<string>,
1976
+ * q: Array<[Number, string] >,
1969
1977
* i: Array<Number>,
1970
1978
* f: Array<RawFunctionSearchType>,
1971
1979
* p: Array<Object>,
1980
+ * c: Array<Number>
1972
1981
* }}
1973
1982
*/
1974
1983
const crateCorpus = rawSearchIndex [ crate ] ;
@@ -1987,6 +1996,7 @@ function initSearch(rawSearchIndex) {
1987
1996
type : null ,
1988
1997
id : id ,
1989
1998
normalizedName : crate . indexOf ( "_" ) === - 1 ? crate : crate . replace ( / _ / g, "" ) ,
1999
+ deprecated : null ,
1990
2000
} ;
1991
2001
id += 1 ;
1992
2002
searchIndex . push ( crateRow ) ;
@@ -1996,14 +2006,20 @@ function initSearch(rawSearchIndex) {
1996
2006
const itemTypes = crateCorpus . t ;
1997
2007
// an array of (String) item names
1998
2008
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 ) ;
2001
2015
// an array of (String) descriptions
2002
2016
const itemDescs = crateCorpus . d ;
2003
2017
// an array of (Number) the parent path index + 1 to `paths`, or 0 if none
2004
2018
const itemParentIdxs = crateCorpus . i ;
2005
2019
// an array of (Object | null) the type of the function, if any
2006
2020
const itemFunctionSearchTypes = crateCorpus . f ;
2021
+ // an array of (Number) indices for the deprecated items
2022
+ const deprecatedItems = new Set ( crateCorpus . c ) ;
2007
2023
// an array of [(Number) item type,
2008
2024
// (String) name]
2009
2025
const paths = crateCorpus . p ;
@@ -2045,12 +2061,13 @@ function initSearch(rawSearchIndex) {
2045
2061
crate : crate ,
2046
2062
ty : itemTypes [ i ] ,
2047
2063
name : itemNames [ i ] ,
2048
- path : itemPaths [ i ] ? itemPaths [ i ] : lastPath ,
2064
+ path : itemPaths . has ( i ) ? itemPaths . get ( i ) : lastPath ,
2049
2065
desc : itemDescs [ i ] ,
2050
2066
parent : itemParentIdxs [ i ] > 0 ? paths [ itemParentIdxs [ i ] - 1 ] : undefined ,
2051
2067
type : buildFunctionSearchType ( itemFunctionSearchTypes [ i ] , lowercasePaths ) ,
2052
2068
id : id ,
2053
2069
normalizedName : word . indexOf ( "_" ) === - 1 ? word : word . replace ( / _ / g, "" ) ,
2070
+ deprecated : deprecatedItems . has ( i ) ,
2054
2071
} ;
2055
2072
id += 1 ;
2056
2073
searchIndex . push ( row ) ;
0 commit comments