From e5438dc586dbce2c15850939a828c9120e23a50c Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 19 May 2025 11:44:08 +0000 Subject: [PATCH] refactor(ast): inline `Comment` newline flags setters (#11150) Follow-on after #11096. Add `#[inline]` to these trivial functions. Usually they're called with a static value, so if they're inlined compiler will be able to remove the branch. Probably compiler would inline these anyway as they're so small, but just to make sure. --- crates/oxc_ast/src/ast/comment.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/oxc_ast/src/ast/comment.rs b/crates/oxc_ast/src/ast/comment.rs index 3efdafe95603c..f80e9f6fdd75f 100644 --- a/crates/oxc_ast/src/ast/comment.rs +++ b/crates/oxc_ast/src/ast/comment.rs @@ -252,6 +252,7 @@ impl Comment { } /// Sets the state of `newlines` to include/exclude a newline after the comment. + #[inline] pub fn set_followed_by_newline(&mut self, followed_by_newline: bool) { if followed_by_newline { self.newlines.insert(CommentNewlines::TRAILING); @@ -261,6 +262,7 @@ impl Comment { } /// Sets the state of `newlines` to include/exclude a newline before the comment. + #[inline] pub fn set_preceded_by_newline(&mut self, preceded_by_newline: bool) { if preceded_by_newline { self.newlines.insert(CommentNewlines::LEADING);