@@ -80,10 +80,6 @@ const longItemTypes = [
80
80
const TY_GENERIC = itemTypes . indexOf ( "generic" ) ;
81
81
const ROOT_PATH = typeof window !== "undefined" ? window . rootPath : "../" ;
82
82
83
- function hasOwnPropertyRustdoc ( obj , property ) {
84
- return Object . prototype . hasOwnProperty . call ( obj , property ) ;
85
- }
86
-
87
83
// In the search display, allows to switch between tabs.
88
84
function printTab ( nb ) {
89
85
let iter = 0 ;
@@ -1068,7 +1064,7 @@ function initSearch(rawSearchIndex) {
1068
1064
1069
1065
if ( elem &&
1070
1066
elem . value !== "all crates" &&
1071
- hasOwnPropertyRustdoc ( rawSearchIndex , elem . value )
1067
+ rawSearchIndex . has ( elem . value )
1072
1068
) {
1073
1069
return elem . value ;
1074
1070
}
@@ -2552,11 +2548,10 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2552
2548
}
2553
2549
2554
2550
let crates = "" ;
2555
- const crates_list = Object . keys ( rawSearchIndex ) ;
2556
- if ( crates_list . length > 1 ) {
2551
+ if ( rawSearchIndex . size > 1 ) {
2557
2552
crates = " in <div id=\"crate-search-div\"><select id=\"crate-search\">" +
2558
2553
"<option value=\"all crates\">all crates</option>" ;
2559
- for ( const c of crates_list ) {
2554
+ for ( const c of rawSearchIndex . keys ( ) ) {
2560
2555
crates += `<option value="${ c } " ${ c === filterCrates && "selected" } >${ c } </option>` ;
2561
2556
}
2562
2557
crates += "</select></div>" ;
@@ -2859,68 +2854,60 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2859
2854
typeNameIdOfSlice = buildTypeMapIndex ( "slice" ) ;
2860
2855
typeNameIdOfArrayOrSlice = buildTypeMapIndex ( "[]" ) ;
2861
2856
2862
- for ( const crate in rawSearchIndex ) {
2863
- if ( ! hasOwnPropertyRustdoc ( rawSearchIndex , crate ) ) {
2864
- continue ;
2865
- }
2866
-
2867
- let crateSize = 0 ;
2868
-
2869
- /**
2870
- * The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f`
2871
- * are arrays with the same length. `q`, `a`, and `c` use a sparse
2872
- * representation for compactness.
2873
- *
2874
- * `n[i]` contains the name of an item.
2875
- *
2876
- * `t[i]` contains the type of that item
2877
- * (as a string of characters that represent an offset in `itemTypes`).
2878
- *
2879
- * `d[i]` contains the description of that item.
2880
- *
2881
- * `q` contains the full paths of the items. For compactness, it is a set of
2882
- * (index, path) pairs used to create a map. If a given index `i` is
2883
- * not present, this indicates "same as the last index present".
2884
- *
2885
- * `i[i]` contains an item's parent, usually a module. For compactness,
2886
- * it is a set of indexes into the `p` array.
2887
- *
2888
- * `f[i]` contains function signatures, or `0` if the item isn't a function.
2889
- * Functions are themselves encoded as arrays. The first item is a list of
2890
- * types representing the function's inputs, and the second list item is a list
2891
- * of types representing the function's output. Tuples are flattened.
2892
- * Types are also represented as arrays; the first item is an index into the `p`
2893
- * array, while the second is a list of types representing any generic parameters.
2894
- *
2895
- * b[i] contains an item's impl disambiguator. This is only present if an item
2896
- * is defined in an impl block and, the impl block's type has more than one associated
2897
- * item with the same name.
2898
- *
2899
- * `a` defines aliases with an Array of pairs: [name, offset], where `offset`
2900
- * points into the n/t/d/q/i/f arrays.
2901
- *
2902
- * `doc` contains the description of the crate.
2903
- *
2904
- * `p` is a list of path/type pairs. It is used for parents and function parameters.
2905
- *
2906
- * `c` is an array of item indices that are deprecated.
2907
- *
2908
- * @type {{
2909
- * doc: string,
2910
- * a: Object,
2911
- * n: Array<string>,
2912
- * t: String,
2913
- * d: Array<string>,
2914
- * q: Array<[Number, string]>,
2915
- * i: Array<Number>,
2916
- * f: Array<RawFunctionSearchType>,
2917
- * p: Array<Object>,
2918
- * b: Array<[Number, String]>,
2919
- * c: Array<Number>
2920
- * }}
2921
- */
2922
- const crateCorpus = rawSearchIndex [ crate ] ;
2923
-
2857
+ /**
2858
+ * The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f`
2859
+ * are arrays with the same length. `q`, `a`, and `c` use a sparse
2860
+ * representation for compactness.
2861
+ *
2862
+ * `n[i]` contains the name of an item.
2863
+ *
2864
+ * `t[i]` contains the type of that item
2865
+ * (as a string of characters that represent an offset in `itemTypes`).
2866
+ *
2867
+ * `d[i]` contains the description of that item.
2868
+ *
2869
+ * `q` contains the full paths of the items. For compactness, it is a set of
2870
+ * (index, path) pairs used to create a map. If a given index `i` is
2871
+ * not present, this indicates "same as the last index present".
2872
+ *
2873
+ * `i[i]` contains an item's parent, usually a module. For compactness,
2874
+ * it is a set of indexes into the `p` array.
2875
+ *
2876
+ * `f[i]` contains function signatures, or `0` if the item isn't a function.
2877
+ * Functions are themselves encoded as arrays. The first item is a list of
2878
+ * types representing the function's inputs, and the second list item is a list
2879
+ * of types representing the function's output. Tuples are flattened.
2880
+ * Types are also represented as arrays; the first item is an index into the `p`
2881
+ * array, while the second is a list of types representing any generic parameters.
2882
+ *
2883
+ * b[i] contains an item's impl disambiguator. This is only present if an item
2884
+ * is defined in an impl block and, the impl block's type has more than one associated
2885
+ * item with the same name.
2886
+ *
2887
+ * `a` defines aliases with an Array of pairs: [name, offset], where `offset`
2888
+ * points into the n/t/d/q/i/f arrays.
2889
+ *
2890
+ * `doc` contains the description of the crate.
2891
+ *
2892
+ * `p` is a list of path/type pairs. It is used for parents and function parameters.
2893
+ *
2894
+ * `c` is an array of item indices that are deprecated.
2895
+ *
2896
+ * @type {{
2897
+ * doc: string,
2898
+ * a: Object,
2899
+ * n: Array<string>,
2900
+ * t: String,
2901
+ * d: Array<string>,
2902
+ * q: Array<[Number, string]>,
2903
+ * i: Array<Number>,
2904
+ * f: Array<RawFunctionSearchType>,
2905
+ * p: Array<Object>,
2906
+ * b: Array<[Number, String]>,
2907
+ * c: Array<Number>
2908
+ * }}
2909
+ */
2910
+ for ( const [ crate , crateCorpus ] of rawSearchIndex ) {
2924
2911
searchWords . push ( crate ) ;
2925
2912
// This object should have exactly the same set of fields as the "row"
2926
2913
// object defined below. Your JavaScript runtime will thank you.
@@ -3027,14 +3014,13 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3027
3014
id += 1 ;
3028
3015
searchIndex . push ( row ) ;
3029
3016
lastPath = row . path ;
3030
- crateSize += 1 ;
3031
3017
}
3032
3018
3033
3019
if ( aliases ) {
3034
3020
const currentCrateAliases = new Map ( ) ;
3035
3021
ALIASES . set ( crate , currentCrateAliases ) ;
3036
3022
for ( const alias_name in aliases ) {
3037
- if ( ! hasOwnPropertyRustdoc ( aliases , alias_name ) ) {
3023
+ if ( ! Object . prototype . hasOwnProperty . call ( aliases , alias_name ) ) {
3038
3024
continue ;
3039
3025
}
3040
3026
@@ -3050,7 +3036,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3050
3036
}
3051
3037
}
3052
3038
}
3053
- currentIndex += crateSize ;
3039
+ currentIndex += itemTypes . length ;
3054
3040
}
3055
3041
return searchWords ;
3056
3042
}
@@ -3259,7 +3245,7 @@ if (typeof window !== "undefined") {
3259
3245
} else {
3260
3246
// Running in Node, not a browser. Run initSearch just to produce the
3261
3247
// exports.
3262
- initSearch ( { } ) ;
3248
+ initSearch ( new Map ( ) ) ;
3263
3249
}
3264
3250
3265
3251
0 commit comments