perf(minifier): use Ident instead of Str in KeepVar (#26332)

Use `Ident` instead of `Str` in `KeepVar`. This reduces the `Ident` -> `Str` -> `Ident` conversion.

I used AI to generate the code and then reviewed the code.
This commit is contained in:
sapphi-red committed 2026-09-06 07:32:33 +00:00
1 parent 51366fb9ff
commit 5b3e335484
1 file changed
+3 -3
+3 -3
View File
@@ -3,11 +3,11 @@ use oxc_ast::{ast::*, builder::GetAstBuilder};
use oxc_ast_visit::VisitJs;
use oxc_ecmascript::BoundNames;
use oxc_span::{SPAN, Span};
use oxc_str::Str;
use oxc_str::Ident;
use oxc_syntax::symbol::SymbolId;
pub struct KeepVar<'a> {
vars: Vec<(Str<'a>, Span, Option<SymbolId>)>,
vars: Vec<(Ident<'a>, Span, Option<SymbolId>)>,
all_hoisted: bool,
}
@@ -45,7 +45,7 @@ impl<'a> VisitJs<'a> for KeepVar<'a> {
fn visit_variable_declaration(&mut self, it: &VariableDeclaration<'a>) {
if it.kind.is_var() {
it.bound_names(&mut |ident| {
self.vars.push((ident.name.into(), ident.span, ident.symbol_id.get()));
self.vars.push((ident.name, ident.span, ident.symbol_id.get()));
});
if it.has_init() {
self.all_hoisted = false;