Skip to content

Commit

Permalink
refactor(transformer): JSX: use AstBuilder::vec_from_iter (#5862)
Browse files Browse the repository at this point in the history
Pure refactor. Shorten code a little by using `AstBuilder::vec_from_iter`.
  • Loading branch information
overlookmotel committed Sep 19, 2024
1 parent 74364ad commit 52c9903
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/oxc_transformer/src/react/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,20 +532,17 @@ impl<'a> ReactJsx<'a> {

// Append children to object properties in automatic mode
if is_automatic {
let allocator = self.ast().allocator;
let mut children = Vec::from_iter_in(
let mut children = self.ast().vec_from_iter(
children.iter().filter_map(|child| self.transform_jsx_child(child, ctx)),
allocator,
);
children_len = children.len();
if children_len != 0 {
let value = if children_len == 1 {
children.pop().unwrap()
} else {
let elements = Vec::from_iter_in(
children.into_iter().map(ArrayExpressionElement::from),
allocator,
);
let elements = self
.ast()
.vec_from_iter(children.into_iter().map(ArrayExpressionElement::from));
need_jsxs = true;
self.ast().expression_array(SPAN, elements, None)
};
Expand Down

0 comments on commit 52c9903

Please sign in to comment.