@@ -488,7 +488,7 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
488488 }
489489
490490 let mut call_expr: Option < CallExpression < ' a > > = None ;
491- let mut props = vec ! [ ] ;
491+ let mut props = ctx . ast . vec_with_capacity ( obj_expr . properties . len ( ) ) ;
492492
493493 for prop in obj_expr. properties . drain ( ..) {
494494 if let ObjectPropertyKind :: SpreadProperty ( spread_prop) = prop {
@@ -509,12 +509,17 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
509509
510510 fn make_object_spread (
511511 expr : & mut Option < CallExpression < ' a > > ,
512- props : & mut Vec < ObjectPropertyKind < ' a > > ,
512+ props : & mut ArenaVec < ' a , ObjectPropertyKind < ' a > > ,
513513 transform_ctx : & ' ctx TransformCtx < ' a > ,
514514 ctx : & mut TraverseCtx < ' a > ,
515515 ) {
516516 let had_props = !props. is_empty ( ) ;
517- let obj = ctx. ast . expression_object ( SPAN , ctx. ast . vec_from_iter ( props. drain ( ..) ) , None ) ;
517+ let obj = ctx. ast . expression_object (
518+ SPAN ,
519+ // Reserve maximize might be used space for new vec
520+ mem:: replace ( props, ctx. ast . vec_with_capacity ( props. capacity ( ) - props. len ( ) ) ) ,
521+ None ,
522+ ) ;
518523 let arguments = if let Some ( call_expr) = expr. take ( ) {
519524 let arg = Expression :: CallExpression ( ctx. ast . alloc ( call_expr) ) ;
520525 let arg = Argument :: from ( arg) ;
0 commit comments