mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-14 22:29:17 +00:00
perf(isolated_declarations): avoid large types on stack (#25036)
Continuation of #25034. In isolated declarations, move some allocations to happen earlier. When we need an `ArenaBox<T>` for later method calls, it's preferable to allocate it into arena as swiftly as possible, so only hold an 8-byte `ArenaBox` on stack, instead of the whole `T`, which is much larger. This reduces stack and register pressure.
This commit is contained in:
1 parent
9fb1e3e2e4
commit
e07718f887
4 files changed
+5
-5
No files matched your search
@@ -711,7 +711,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
elements.insert(0, element);
|
||||
}
|
||||
|
||||
let body = ClassBody::new(decl.body.span, elements, self);
|
||||
let body = ClassBody::boxed(decl.body.span, elements, self);
|
||||
|
||||
Class::boxed(
|
||||
decl.span,
|
||||
|
||||
@@ -99,7 +99,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
}
|
||||
|
||||
let type_annotation =
|
||||
binding_type.map(|ts_type| TSTypeAnnotation::new(SPAN, ts_type, self));
|
||||
binding_type.map(|ts_type| TSTypeAnnotation::boxed(SPAN, ts_type, self));
|
||||
|
||||
Some(VariableDeclarator::new(
|
||||
decl.span,
|
||||
|
||||
@@ -92,7 +92,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
self.error(implicitly_adding_undefined_to_type(param.span));
|
||||
} else if !ts_type.is_maybe_undefined() {
|
||||
// union with `undefined`
|
||||
return TSTypeAnnotation::new(
|
||||
return TSTypeAnnotation::boxed(
|
||||
SPAN,
|
||||
TSType::new_ts_union_type(
|
||||
SPAN,
|
||||
@@ -104,7 +104,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
TSTypeAnnotation::new(SPAN, ts_type, self)
|
||||
TSTypeAnnotation::boxed(SPAN, ts_type, self)
|
||||
});
|
||||
|
||||
let optional =
|
||||
|
||||
@@ -100,7 +100,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
let id = BindingPattern::new_binding_identifier(SPAN, name, self);
|
||||
let type_annotation = self
|
||||
.infer_type_from_expression(expr)
|
||||
.map(|ts_type| TSTypeAnnotation::new(SPAN, ts_type, self));
|
||||
.map(|ts_type| TSTypeAnnotation::boxed(SPAN, ts_type, self));
|
||||
|
||||
if type_annotation.is_none() {
|
||||
self.error(default_export_inferred(expr.span()));
|
||||
|
||||
Reference in new issue
Block a user