Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions crates/oxc_transformer/src/common/helper_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use std::{borrow::Cow, cell::RefCell};
use rustc_hash::FxHashMap;
use serde::Deserialize;

use oxc_allocator::{String as ArenaString, Vec as ArenaVec};
use oxc_allocator::Vec as ArenaVec;
use oxc_ast::{
NONE,
ast::{Argument, CallExpression, Expression},
Expand Down Expand Up @@ -313,13 +313,7 @@ impl<'a> HelperLoaderStore<'a> {

// Construct string directly in arena without an intermediate temp allocation
fn get_runtime_source(&self, helper: Helper, ctx: &TraverseCtx<'a>) -> Atom<'a> {
let helper_name = helper.name();
let len = self.module_name.len() + "/helpers/".len() + helper_name.len();
let mut source = ArenaString::with_capacity_in(len, ctx.ast.allocator);
source.push_str(&self.module_name);
source.push_str("/helpers/");
source.push_str(helper_name);
Atom::from(source)
ctx.ast.atom_from_strs_array([&self.module_name, "/helpers/", helper.name()])
}

fn transform_for_external_helper(helper: Helper, ctx: &mut TraverseCtx<'a>) -> Expression<'a> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::mem;

use oxc_allocator::{Box as ArenaBox, String as ArenaString};
use oxc_allocator::Box as ArenaBox;
use oxc_ast::{NONE, ast::*};
use oxc_span::SPAN;
use oxc_syntax::{reference::ReferenceId, symbol::SymbolId};
Expand Down Expand Up @@ -2176,10 +2176,8 @@ impl<'a> ClassProperties<'a, '_> {
private_name: &str,
ctx: &mut TraverseCtx<'a>,
) -> Expression<'a> {
let mut message = ArenaString::with_capacity_in(private_name.len() + 1, ctx.ast.allocator);
message.push('#');
message.push_str(private_name);
let message = ctx.ast.expression_string_literal(SPAN, message.into_bump_str(), None);
let message = ctx.ast.atom_from_strs_array(["#", private_name]);
let message = ctx.ast.expression_string_literal(SPAN, message, None);
self.ctx.helper_call_expr(helper, SPAN, ctx.ast.vec1(Argument::from(message)), ctx)
}

Expand Down
7 changes: 1 addition & 6 deletions crates/oxc_transformer/src/es2022/class_static_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

use itoa::Buffer as ItoaBuffer;

use oxc_allocator::String as ArenaString;
use oxc_ast::{NONE, ast::*};
use oxc_span::SPAN;
use oxc_syntax::scope::{ScopeFlags, ScopeId};
Expand Down Expand Up @@ -251,11 +250,7 @@ impl<'a> Keys<'a> {
i += 1;
}

let mut key = ArenaString::with_capacity_in(num_str.len() + 1, ctx.ast.allocator);
key.push('_');
key.push_str(num_str);
let key = Atom::from(key);

let key = ctx.ast.atom_from_strs_array(["_", num_str]);
self.numbered.push(&key.as_str()[1..]);

key
Expand Down
12 changes: 3 additions & 9 deletions crates/oxc_transformer/src/plugins/module_runner_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use compact_str::ToCompactString;
use rustc_hash::FxHashMap;
use std::iter;

use oxc_allocator::{Allocator, Box as ArenaBox, String as ArenaString, Vec as ArenaVec};
use oxc_allocator::{Allocator, Box as ArenaBox, Vec as ArenaVec};
use oxc_ast::{NONE, ast::*};
use oxc_ecmascript::BoundNames;
use oxc_semantic::{ReferenceFlags, ScopeFlags, ScopeTree, SymbolFlags, SymbolId, SymbolTable};
Expand Down Expand Up @@ -641,15 +641,9 @@ impl<'a> ModuleRunnerTransform<'a> {

/// Generate a unique import binding name like `__vite_ssr_import_{uid}__`.
fn generate_import_binding_name(&mut self, ctx: &TraverseCtx<'a>) -> Atom<'a> {
let uid = self.import_uid.to_compact_string();
let uid_str = &self.import_uid.to_compact_string();
self.import_uid += 1;
let capacity = 20 + uid.len();
let mut string = ArenaString::with_capacity_in(capacity, ctx.ast.allocator);
string.push_str("__vite_ssr_import_");
string.push_str(&uid);
string.push_str("__");
debug_assert_eq!(string.len(), capacity);
Atom::from(string)
ctx.ast.atom_from_strs_array(["__vite_ssr_import_", uid_str, "__"])
}

/// Generate a unique import binding whose name is like `__vite_ssr_import_{uid}__`.
Expand Down
Loading