@@ -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
}
@@ -2859,68 +2855,60 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2859
2855
typeNameIdOfSlice = buildTypeMapIndex ( "slice" ) ;
2860
2856
typeNameIdOfArrayOrSlice = buildTypeMapIndex ( "[]" ) ;
2861
2857
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
-
2858
+ /**
2859
+ * The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f`
2860
+ * are arrays with the same length. `q`, `a`, and `c` use a sparse
2861
+ * representation for compactness.
2862
+ *
2863
+ * `n[i]` contains the name of an item.
2864
+ *
2865
+ * `t[i]` contains the type of that item
2866
+ * (as a string of characters that represent an offset in `itemTypes`).
2867
+ *
2868
+ * `d[i]` contains the description of that item.
2869
+ *
2870
+ * `q` contains the full paths of the items. For compactness, it is a set of
2871
+ * (index, path) pairs used to create a map. If a given index `i` is
2872
+ * not present, this indicates "same as the last index present".
2873
+ *
2874
+ * `i[i]` contains an item's parent, usually a module. For compactness,
2875
+ * it is a set of indexes into the `p` array.
2876
+ *
2877
+ * `f[i]` contains function signatures, or `0` if the item isn't a function.
2878
+ * Functions are themselves encoded as arrays. The first item is a list of
2879
+ * types representing the function's inputs, and the second list item is a list
2880
+ * of types representing the function's output. Tuples are flattened.
2881
+ * Types are also represented as arrays; the first item is an index into the `p`
2882
+ * array, while the second is a list of types representing any generic parameters.
2883
+ *
2884
+ * b[i] contains an item's impl disambiguator. This is only present if an item
2885
+ * is defined in an impl block and, the impl block's type has more than one associated
2886
+ * item with the same name.
2887
+ *
2888
+ * `a` defines aliases with an Array of pairs: [name, offset], where `offset`
2889
+ * points into the n/t/d/q/i/f arrays.
2890
+ *
2891
+ * `doc` contains the description of the crate.
2892
+ *
2893
+ * `p` is a list of path/type pairs. It is used for parents and function parameters.
2894
+ *
2895
+ * `c` is an array of item indices that are deprecated.
2896
+ *
2897
+ * @type {{
2898
+ * doc: string,
2899
+ * a: Object,
2900
+ * n: Array<string>,
2901
+ * t: String,
2902
+ * d: Array<string>,
2903
+ * q: Array<[Number, string]>,
2904
+ * i: Array<Number>,
2905
+ * f: Array<RawFunctionSearchType>,
2906
+ * p: Array<Object>,
2907
+ * b: Array<[Number, String]>,
2908
+ * c: Array<Number>
2909
+ * }}
2910
+ */
2911
+ for ( const [ crate , crateCorpus ] of rawSearchIndex ) {
2924
2912
searchWords . push ( crate ) ;
2925
2913
// This object should have exactly the same set of fields as the "row"
2926
2914
// object defined below. Your JavaScript runtime will thank you.
@@ -3027,14 +3015,13 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3027
3015
id += 1 ;
3028
3016
searchIndex . push ( row ) ;
3029
3017
lastPath = row . path ;
3030
- crateSize += 1 ;
3031
3018
}
3032
3019
3033
3020
if ( aliases ) {
3034
3021
const currentCrateAliases = new Map ( ) ;
3035
3022
ALIASES . set ( crate , currentCrateAliases ) ;
3036
3023
for ( const alias_name in aliases ) {
3037
- if ( ! hasOwnPropertyRustdoc ( aliases , alias_name ) ) {
3024
+ if ( ! Object . prototype . hasOwnProperty . call ( aliases , alias_name ) ) {
3038
3025
continue ;
3039
3026
}
3040
3027
@@ -3050,7 +3037,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3050
3037
}
3051
3038
}
3052
3039
}
3053
- currentIndex += crateSize ;
3040
+ currentIndex += itemTypes . length ;
3054
3041
}
3055
3042
return searchWords ;
3056
3043
}
@@ -3259,7 +3246,7 @@ if (typeof window !== "undefined") {
3259
3246
} else {
3260
3247
// Running in Node, not a browser. Run initSearch just to produce the
3261
3248
// exports.
3262
- initSearch ( { } ) ;
3249
+ initSearch ( new Map ( ) ) ;
3263
3250
}
3264
3251
3265
3252
0 commit comments