mirror of
https://github.com/danbulant/oxc
synced 2026-05-22 21:58:36 +00:00
perf(parser): do not copy comments (#4067)
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.
This commit is contained in:
parent
8fa98e03ae
commit
7fe2a2f681
1 changed files with 2 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use oxc_ast::{Comment, CommentKind, SortedComments, Trivias};
|
use oxc_ast::{Comment, CommentKind, Trivias};
|
||||||
use oxc_span::Span;
|
use oxc_span::Span;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
@ -12,8 +12,7 @@ pub struct TriviaBuilder {
|
||||||
|
|
||||||
impl TriviaBuilder {
|
impl TriviaBuilder {
|
||||||
pub fn build(self) -> Trivias {
|
pub fn build(self) -> Trivias {
|
||||||
let comments = SortedComments::from_iter(self.comments);
|
Trivias::new(self.comments.into_boxed_slice(), self.irregular_whitespaces)
|
||||||
Trivias::new(comments, self.irregular_whitespaces)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_single_line_comment(&mut self, start: u32, end: u32) {
|
pub fn add_single_line_comment(&mut self, start: u32, end: u32) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue