From 1458d8126843fc750909b39f4d00b586d4cd1439 Mon Sep 17 00:00:00 2001
From: overlookmotel <557937+overlookmotel@users.noreply.github.com>
Date: Wed, 17 Jul 2024 17:10:36 +0000
Subject: [PATCH] refactor(visit): add `#[inline]` to empty functions (#4330)
Add `#[inline]` to empty default implementations of `enter_node` etc. Hopefully compiler will inline them automatically within Oxc even cross-crate because we compile with LTO, but maybe not for external consumers who don't use LTO.
---
crates/oxc_ast/src/generated/visit.rs | 4 ++++
crates/oxc_ast/src/generated/visit_mut.rs | 4 ++++
tasks/ast_codegen/src/generators/visit.rs | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs
index b953314fc94e6..79a63005754d4 100644
--- a/crates/oxc_ast/src/generated/visit.rs
+++ b/crates/oxc_ast/src/generated/visit.rs
@@ -27,10 +27,14 @@ use walk::*;
/// Syntax tree traversal
pub trait Visit<'a>: Sized {
+ #[inline]
fn enter_node(&mut self, kind: AstKind<'a>) {}
+ #[inline]
fn leave_node(&mut self, kind: AstKind<'a>) {}
+ #[inline]
fn enter_scope(&mut self, flags: ScopeFlags, scope_id: &Cell