refactor(ast): reduce allocations in AstBuilder::move_assignment_target (#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.
This commit is contained in:
overlookmotel 2024-08-31 08:34:26 +00:00
parent 1d9fd1fdcc
commit c2d8c9e743

View file

@ -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())
}