1
- use std:: collections:: hash_map:: Entry ;
1
+ use std:: { collections:: hash_map:: Entry , mem } ;
2
2
3
3
use base64:: {
4
4
encoded_len as base64_encoded_len,
@@ -139,8 +139,8 @@ impl<'a, 'ctx> ReactRefresh<'a, 'ctx> {
139
139
140
140
impl < ' a > Traverse < ' a > for ReactRefresh < ' a , ' _ > {
141
141
fn enter_program ( & mut self , program : & mut Program < ' a > , ctx : & mut TraverseCtx < ' a > ) {
142
- let mut new_statements = ctx. ast . vec_with_capacity ( program. body . len ( ) ) ;
143
- for mut statement in program. body . drain ( .. ) {
142
+ let mut new_statements = ctx. ast . vec_with_capacity ( program. body . len ( ) * 2 ) ;
143
+ for mut statement in program. body . take_in ( ctx . ast . allocator ) {
144
144
let next_statement = self . process_statement ( & mut statement, ctx) ;
145
145
new_statements. push ( statement) ;
146
146
if let Some ( assignment_expression) = next_statement {
@@ -156,8 +156,8 @@ impl<'a> Traverse<'a> for ReactRefresh<'a, '_> {
156
156
}
157
157
158
158
let mut variable_declarator_items = ctx. ast . vec_with_capacity ( self . registrations . len ( ) ) ;
159
- let mut new_statements = ctx. ast . vec_with_capacity ( self . registrations . len ( ) + 1 ) ;
160
- for ( binding, persistent_id) in self . registrations . drain ( .. ) {
159
+ let mut new_statements = ctx. ast . vec_with_capacity ( self . registrations . len ( ) ) ;
160
+ for ( binding, persistent_id) in mem :: take ( & mut self . registrations ) {
161
161
variable_declarator_items. push ( ctx. ast . variable_declarator (
162
162
SPAN ,
163
163
VariableDeclarationKind :: Var ,
0 commit comments