Skip to content

Commit b4b0ed8

Browse files
committed
perf(transformer/typescript): reverse order of checks (#15722)
Tiny perf optimization. It's cheaper to check `declare` property once you know the type of the `Declaration`. `Declaration::declare` has to branch on the type of the `Declaration`.
1 parent cbb27fd commit b4b0ed8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/oxc_transformer/src/typescript/namespace.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for TypeScriptNamespace<'a, '_> {
6565
if export_decl.declaration.as_ref().is_some_and(|declaration| {
6666
// Note: No need to check for `TSGlobalDeclaration` here, as it can't be exported
6767
debug_assert!(!matches!(declaration, Declaration::TSGlobalDeclaration(_)));
68-
!declaration.declare()
69-
&& matches!(declaration, Declaration::TSModuleDeclaration(_))
68+
matches!(declaration, Declaration::TSModuleDeclaration(module_decl) if !module_decl.declare)
7069
}) =>
7170
{
7271
let Some(Declaration::TSModuleDeclaration(decl)) =

0 commit comments

Comments
 (0)