@@ -121,7 +121,7 @@ impl<'a> IsolatedDeclarations<'a> {
121
121
let mut new_stmts = Vec :: new ( ) ;
122
122
let mut variables_declarations = VecDeque :: new ( ) ;
123
123
let mut variable_transformed_indexes = VecDeque :: new ( ) ;
124
- let mut transformed_indexes = Vec :: new ( ) ;
124
+ let mut transformed_indexes = FxHashSet :: default ( ) ;
125
125
// 1. Collect all declarations, module declarations
126
126
// 2. Transform export declarations
127
127
// 3. Collect all bindings / reference from module declarations
@@ -134,18 +134,18 @@ impl<'a> IsolatedDeclarations<'a> {
134
134
variables_declarations. push_back (
135
135
self . ast . copy ( & decl. declarations ) . into_iter ( ) . collect :: < Vec < _ > > ( ) ,
136
136
) ;
137
- variable_transformed_indexes. push_back ( Vec :: default ( ) ) ;
137
+ variable_transformed_indexes. push_back ( FxHashSet :: default ( ) ) ;
138
138
}
139
139
Declaration :: UsingDeclaration ( decl) => {
140
140
variables_declarations. push_back (
141
141
self . ast . copy ( & decl. declarations ) . into_iter ( ) . collect :: < Vec < _ > > ( ) ,
142
142
) ;
143
- variable_transformed_indexes. push_back ( Vec :: default ( ) ) ;
143
+ variable_transformed_indexes. push_back ( FxHashSet :: default ( ) ) ;
144
144
}
145
145
Declaration :: TSModuleDeclaration ( decl) => {
146
146
if decl. kind . is_global ( ) {
147
147
self . scope . visit_ts_module_declaration ( decl) ;
148
- transformed_indexes. push ( new_stmts. len ( ) ) ;
148
+ transformed_indexes. insert ( new_stmts. len ( ) ) ;
149
149
}
150
150
}
151
151
_ => { }
@@ -155,7 +155,7 @@ impl<'a> IsolatedDeclarations<'a> {
155
155
match_module_declaration ! ( Statement ) => {
156
156
match stmt. to_module_declaration ( ) {
157
157
ModuleDeclaration :: ExportDefaultDeclaration ( decl) => {
158
- transformed_indexes. push ( new_stmts. len ( ) ) ;
158
+ transformed_indexes. insert ( new_stmts. len ( ) ) ;
159
159
if let Some ( ( var_decl, new_decl) ) =
160
160
self . transform_export_default_declaration ( decl)
161
161
{
@@ -165,7 +165,7 @@ impl<'a> IsolatedDeclarations<'a> {
165
165
new_stmts. push ( Statement :: VariableDeclaration (
166
166
self . ast . alloc ( var_decl) ,
167
167
) ) ;
168
- transformed_indexes. push ( new_stmts. len ( ) ) ;
168
+ transformed_indexes. insert ( new_stmts. len ( ) ) ;
169
169
}
170
170
171
171
self . scope . visit_export_default_declaration ( & new_decl) ;
@@ -180,7 +180,7 @@ impl<'a> IsolatedDeclarations<'a> {
180
180
}
181
181
182
182
ModuleDeclaration :: ExportNamedDeclaration ( decl) => {
183
- transformed_indexes. push ( new_stmts. len ( ) ) ;
183
+ transformed_indexes. insert ( new_stmts. len ( ) ) ;
184
184
if let Some ( new_decl) = self . transform_export_named_declaration ( decl) {
185
185
self . scope . visit_declaration (
186
186
new_decl. declaration . as_ref ( ) . unwrap_or_else ( || unreachable ! ( ) ) ,
@@ -198,7 +198,7 @@ impl<'a> IsolatedDeclarations<'a> {
198
198
// We must transform this in the end, because we need to know all references
199
199
}
200
200
module_declaration => {
201
- transformed_indexes. push ( new_stmts. len ( ) ) ;
201
+ transformed_indexes. insert ( new_stmts. len ( ) ) ;
202
202
self . scope . visit_module_declaration ( module_declaration) ;
203
203
}
204
204
}
@@ -241,13 +241,13 @@ impl<'a> IsolatedDeclarations<'a> {
241
241
242
242
if let Some ( decl) = self . transform_variable_declarator ( declarator, true ) {
243
243
self . scope . visit_variable_declarator ( & decl) ;
244
- cur_transformed_indexes. push ( ii) ;
244
+ cur_transformed_indexes. insert ( ii) ;
245
245
* declarator = decl;
246
246
}
247
247
}
248
248
} else if let Some ( decl) = self . transform_declaration ( decl, true ) {
249
249
self . scope . visit_declaration ( & decl) ;
250
- transformed_indexes. push ( i) ;
250
+ transformed_indexes. insert ( i) ;
251
251
* stmt = Statement :: from ( decl) ;
252
252
}
253
253
}
@@ -280,7 +280,7 @@ impl<'a> IsolatedDeclarations<'a> {
280
280
) ,
281
281
) ;
282
282
new_ast_stmts. push ( Statement :: VariableDeclaration ( variables_declaration) ) ;
283
- transformed_indexes. push ( index) ;
283
+ transformed_indexes. insert ( index) ;
284
284
}
285
285
}
286
286
Statement :: UsingDeclaration ( decl) => {
@@ -302,7 +302,7 @@ impl<'a> IsolatedDeclarations<'a> {
302
302
) ,
303
303
) ;
304
304
new_ast_stmts. push ( Statement :: VariableDeclaration ( variable_declaration) ) ;
305
- transformed_indexes. push ( index) ;
305
+ transformed_indexes. insert ( index) ;
306
306
}
307
307
}
308
308
Statement :: ImportDeclaration ( decl) => {
0 commit comments