Skip to content

Commit

Permalink
refactor(ast): inline trivial functions and shorten code (#4066)
Browse files Browse the repository at this point in the history
Follow on from #4045. Mark trivial functions related to `Trivias` as `#[inline]` and remove a couple of unnecessary `matches!` macro calls.
  • Loading branch information
overlookmotel committed Jul 6, 2024
1 parent 564a75a commit 8fa98e0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/oxc_ast/src/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Comment {
}

impl Comment {
#[inline]
pub fn new(end: u32, kind: CommentKind) -> Self {
Self { kind, end }
}
Expand All @@ -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
}
}

Expand All @@ -54,6 +57,7 @@ pub struct TriviasImpl {
impl Deref for Trivias {
type Target = TriviasImpl;

#[inline]
fn deref(&self) -> &Self::Target {
self.0.as_ref()
}
Expand Down

0 comments on commit 8fa98e0

Please sign in to comment.