mirror of
https://github.com/swc-project/swc.git
synced 2024-12-28 16:13:34 +03:00
perf(css/codegen): Skip useless operations if not required (#5802)
**Description:** The column is used only for sourcemap, so we can skip `chars().count()` if we are not generating source maps.
This commit is contained in:
parent
4c078b0ac3
commit
b96eb1ead8
@ -113,7 +113,9 @@ where
|
||||
|
||||
fn raw_write(&mut self, data: &str) -> Result {
|
||||
self.w.write_str(data)?;
|
||||
self.col += data.chars().count();
|
||||
if self.srcmap.is_some() {
|
||||
self.col += data.chars().count();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -216,11 +218,15 @@ where
|
||||
let line_start_of_s = compute_line_starts(s);
|
||||
|
||||
if line_start_of_s.len() > 1 {
|
||||
self.line = self.line + line_start_of_s.len() - 1;
|
||||
if self.srcmap.is_some() {
|
||||
self.line = self.line + line_start_of_s.len() - 1;
|
||||
}
|
||||
|
||||
let last_line_byte_index = line_start_of_s.last().cloned().unwrap_or(0);
|
||||
|
||||
self.col = s[last_line_byte_index..].chars().count();
|
||||
if self.srcmap.is_some() {
|
||||
self.col = s[last_line_byte_index..].chars().count();
|
||||
}
|
||||
}
|
||||
|
||||
if !span.is_dummy() {
|
||||
|
Loading…
Reference in New Issue
Block a user