From 89bdf5536fff9c7a1db783df35d2af7784e90ab5 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 9 Sep 2024 07:13:54 +0000 Subject: [PATCH] refactor(linter): inline `Rule` trait default methods (#5619) Hopefully compiler is already inlining these trivial/empty methods, but mark them `#[inline]` to make sure. --- crates/oxc_linter/src/rule.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/oxc_linter/src/rule.rs b/crates/oxc_linter/src/rule.rs index 67114e5faaa23..31662f8407e7a 100644 --- a/crates/oxc_linter/src/rule.rs +++ b/crates/oxc_linter/src/rule.rs @@ -17,14 +17,17 @@ pub trait Rule: Sized + Default + fmt::Debug { /// Visit each AST Node #[expect(unused_variables)] + #[inline] fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {} /// Visit each symbol #[expect(unused_variables)] + #[inline] fn run_on_symbol(&self, symbol_id: SymbolId, ctx: &LintContext<'_>) {} /// Run only once. Useful for inspecting scopes and trivias etc. #[expect(unused_variables)] + #[inline] fn run_once(&self, ctx: &LintContext) {} /// Check if a rule should be run at all. @@ -35,6 +38,7 @@ pub trait Rule: Sized + Default + fmt::Debug { /// /// [`linter`]: crate::Linter #[expect(unused_variables)] + #[inline] fn should_run(&self, ctx: &LintContext) -> bool { true }