mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
perf(sourcemap): ConcatSourceMapBuilder extend source_contents in separate loop (#4634)
Small optimization to source map concatenation. Check if input sourcemap has `source_contents` once, rather than on each turn of the loop.
This commit is contained in:
parent
0d2c41a2cb
commit
372316bf87
1 changed files with 6 additions and 5 deletions
|
|
@ -46,11 +46,12 @@ impl ConcatSourceMapBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend `sources` and `source_contents`.
|
// Extend `sources` and `source_contents`.
|
||||||
self.sources.reserve(sourcemap.sources.len());
|
self.sources.extend(sourcemap.get_sources().map(Into::into));
|
||||||
for (index, source) in sourcemap.get_sources().enumerate() {
|
|
||||||
let source_content = sourcemap.get_source_content(index as u32).unwrap_or_default();
|
if let Some(source_contents) = &sourcemap.source_contents {
|
||||||
self.sources.push(source.into());
|
self.source_contents.extend(source_contents.iter().map(AsRef::as_ref).map(Into::into));
|
||||||
self.source_contents.push(source_content.into());
|
} else {
|
||||||
|
self.source_contents.extend((0..sourcemap.sources.len()).map(|_| Arc::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend `names`.
|
// Extend `names`.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue