From 8fa98e03ae3f571a70d14d17127e39d3de597e36 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sat, 6 Jul 2024 09:56:36 +0000 Subject: [PATCH] refactor(ast): inline trivial functions and shorten code (#4066) Follow on from #4045. Mark trivial functions related to `Trivias` as `#[inline]` and remove a couple of unnecessary `matches!` macro calls. --- crates/oxc_ast/src/trivia.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/oxc_ast/src/trivia.rs b/crates/oxc_ast/src/trivia.rs index 57333c6029a6..18529150f42e 100644 --- a/crates/oxc_ast/src/trivia.rs +++ b/crates/oxc_ast/src/trivia.rs @@ -16,6 +16,7 @@ pub struct Comment { } impl Comment { + #[inline] pub fn new(end: u32, kind: CommentKind) -> Self { Self { kind, end } } @@ -28,12 +29,14 @@ pub enum CommentKind { } impl CommentKind { + #[inline] pub fn is_single_line(self) -> bool { - matches!(self, Self::SingleLine) + self == Self::SingleLine } + #[inline] pub fn is_multi_line(self) -> bool { - matches!(self, Self::MultiLine) + self == Self::MultiLine } } @@ -54,6 +57,7 @@ pub struct TriviasImpl { impl Deref for Trivias { type Target = TriviasImpl; + #[inline] fn deref(&self) -> &Self::Target { self.0.as_ref() }