Skip to content

Commit

Permalink
perf(parser): do not copy comments (#4067)
Browse files Browse the repository at this point in the history
Follow-on from #4045. `.from_iter()` copies the `Vec` of comments into another `Vec` before converting to a boxed slice. This copy is unnecessary - just convert direct.
  • Loading branch information
overlookmotel committed Jul 6, 2024
1 parent 8fa98e0 commit 7fe2a2f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/oxc_parser/src/lexer/trivia_builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oxc_ast::{Comment, CommentKind, SortedComments, Trivias};
use oxc_ast::{Comment, CommentKind, Trivias};
use oxc_span::Span;

#[derive(Debug, Default)]
Expand All @@ -12,8 +12,7 @@ pub struct TriviaBuilder {

impl TriviaBuilder {
pub fn build(self) -> Trivias {
let comments = SortedComments::from_iter(self.comments);
Trivias::new(comments, self.irregular_whitespaces)
Trivias::new(self.comments.into_boxed_slice(), self.irregular_whitespaces)
}

pub fn add_single_line_comment(&mut self, start: u32, end: u32) {
Expand Down

0 comments on commit 7fe2a2f

Please sign in to comment.