From d62631e23964aa029f1346d7f591d7ec777b1d6d Mon Sep 17 00:00:00 2001 From: Dunqing Date: Sun, 12 Nov 2023 19:26:15 +0800 Subject: [PATCH] refactor(transformer/react-jsx): use extend instead of for-in with push (#1236) --- crates/oxc_transformer/src/react_jsx/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/oxc_transformer/src/react_jsx/mod.rs b/crates/oxc_transformer/src/react_jsx/mod.rs index f958dd117..23ba5422b 100644 --- a/crates/oxc_transformer/src/react_jsx/mod.rs +++ b/crates/oxc_transformer/src/react_jsx/mod.rs @@ -335,7 +335,7 @@ impl<'a> ReactJsx<'a> { } // The object properties for the second argument of `React.createElement` - let mut properties = self.ast.new_vec_with_capacity(0); + let mut properties = self.ast.new_vec(); if let Some(attributes) = attributes { // TODO: compute the correct capacity for both runtimes @@ -585,9 +585,7 @@ impl<'a> ReactJsx<'a> { } JSXAttributeItem::SpreadAttribute(attr) => match &attr.argument { Expression::ObjectExpression(expr) if !expr.has_proto() => { - for object_property in &expr.properties { - properties.push(self.ast.copy(object_property)); - } + properties.extend(self.ast.copy(&expr.properties)); } expr => { let argument = self.ast.copy(expr);