Skip to content

Commit

Permalink
refactor(ast): reduce allocations in `AstBuilder::move_assignment_tar…
Browse files Browse the repository at this point in the history
…get` (#5367)

`AstBuilder::move_assignment_target` pass a static `Atom` instead of empty string to `AstBuilder::simple_assignment_target_identifier_reference`. This avoids a call to `alloc` to allocate an empty string in arena.
  • Loading branch information
overlookmotel committed Aug 31, 2024
1 parent 1d9fd1f commit c2d8c9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ impl<'a> AstBuilder<'a> {

#[inline]
pub fn move_assignment_target(self, target: &mut AssignmentTarget<'a>) -> AssignmentTarget<'a> {
let dummy = self.simple_assignment_target_identifier_reference(Span::default(), "");
let dummy =
self.simple_assignment_target_identifier_reference(Span::default(), Atom::from(""));
mem::replace(target, dummy.into())
}

Expand Down

0 comments on commit c2d8c9e

Please sign in to comment.