@@ -1096,7 +1096,7 @@ function initSearch(rawSearchIndex) {
1096
1096
// The names match, but we need to be sure that all generics kinda
1097
1097
// match as well.
1098
1098
if ( elem . generics . length > 0 && row . generics . length >= elem . generics . length ) {
1099
- const elems = Object . create ( null ) ;
1099
+ const elems = new Map ( ) ;
1100
1100
for ( const entry of row . generics ) {
1101
1101
if ( entry . name === "" ) {
1102
1102
// Pure generic, needs to check into it.
@@ -1106,39 +1106,30 @@ function initSearch(rawSearchIndex) {
1106
1106
}
1107
1107
continue ;
1108
1108
}
1109
- if ( elems [ entry . name ] === undefined ) {
1110
- elems [ entry . name ] = [ ] ;
1109
+ let currentEntryElems ;
1110
+ if ( elems . has ( entry . name ) ) {
1111
+ currentEntryElems = elems . get ( entry . name ) ;
1112
+ } else {
1113
+ currentEntryElems = [ ] ;
1114
+ elems . set ( entry . name , currentEntryElems ) ;
1111
1115
}
1112
- elems [ entry . name ] . push ( entry . ty ) ;
1116
+ currentEntryElems . push ( entry . ty ) ;
1113
1117
}
1114
1118
// We need to find the type that matches the most to remove it in order
1115
1119
// to move forward.
1116
1120
const handleGeneric = generic => {
1117
- let match = null ;
1118
- if ( elems [ generic . name ] ) {
1119
- match = generic . name ;
1120
- } else {
1121
- for ( const elem_name in elems ) {
1122
- if ( ! hasOwnPropertyRustdoc ( elems , elem_name ) ) {
1123
- continue ;
1124
- }
1125
- if ( elem_name === generic ) {
1126
- match = elem_name ;
1127
- break ;
1128
- }
1129
- }
1130
- }
1131
- if ( match === null ) {
1121
+ if ( ! elems . has ( generic . name ) ) {
1132
1122
return false ;
1133
1123
}
1134
- const matchIdx = elems [ match ] . findIndex ( tmp_elem =>
1124
+ const matchElems = elems . get ( generic . name ) ;
1125
+ const matchIdx = matchElems . findIndex ( tmp_elem =>
1135
1126
typePassesFilter ( generic . typeFilter , tmp_elem ) ) ;
1136
1127
if ( matchIdx === - 1 ) {
1137
1128
return false ;
1138
1129
}
1139
- elems [ match ] . splice ( matchIdx , 1 ) ;
1140
- if ( elems [ match ] . length === 0 ) {
1141
- delete elems [ match ] ;
1130
+ matchElems . splice ( matchIdx , 1 ) ;
1131
+ if ( matchElems . length === 0 ) {
1132
+ elems . delete ( generic . name ) ;
1142
1133
}
1143
1134
return true ;
1144
1135
} ;
0 commit comments