mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
perf(codegen): do not check whether there are annotation comments or not if we don't preserve annotation comments (#6107)
This commit is contained in:
parent
8582ae3e91
commit
05852a04ed
1 changed files with 6 additions and 0 deletions
|
|
@ -31,6 +31,9 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_annotation_comment(&self, start: u32) -> bool {
|
pub fn has_annotation_comment(&self, start: u32) -> bool {
|
||||||
|
if !self.preserve_annotate_comments() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
let Some(source_text) = self.source_text else { return false };
|
let Some(source_text) = self.source_text else { return false };
|
||||||
self.comments.get(&start).is_some_and(|comments| {
|
self.comments.get(&start).is_some_and(|comments| {
|
||||||
comments.iter().any(|comment| Self::is_annotation_comment(comment, source_text))
|
comments.iter().any(|comment| Self::is_annotation_comment(comment, source_text))
|
||||||
|
|
@ -38,6 +41,9 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_non_annotation_comment(&self, start: u32) -> bool {
|
pub fn has_non_annotation_comment(&self, start: u32) -> bool {
|
||||||
|
if !self.preserve_annotate_comments() {
|
||||||
|
return self.has_comment(start);
|
||||||
|
}
|
||||||
let Some(source_text) = self.source_text else { return false };
|
let Some(source_text) = self.source_text else { return false };
|
||||||
self.comments.get(&start).is_some_and(|comments| {
|
self.comments.get(&start).is_some_and(|comments| {
|
||||||
comments.iter().any(|comment| !Self::is_annotation_comment(comment, source_text))
|
comments.iter().any(|comment| !Self::is_annotation_comment(comment, source_text))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue