Skip to content

Commit

Permalink
perf(sourcemap): ConcatSourceMapBuilder extend source_contents in…
Browse files Browse the repository at this point in the history
… separate loop
  • Loading branch information
overlookmotel committed Aug 5, 2024
1 parent 439ce5b commit cff8fde
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/oxc_sourcemap/src/concat_sourcemap_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ impl ConcatSourceMapBuilder {
}

// Extend `sources` and `source_contents`.
self.sources.reserve(sourcemap.sources.len());
for (index, source) in sourcemap.get_sources().enumerate() {
let source_content = sourcemap.get_source_content(index as u32).unwrap_or_default();
self.sources.push(source.into());
self.source_contents.push(source_content.into());
self.sources.extend(sourcemap.get_sources().map(Into::into));

if let Some(source_contents) = &sourcemap.source_contents {
self.source_contents.extend(source_contents.iter().map(AsRef::as_ref).map(Into::into));
} else {
self.source_contents.extend((0..sourcemap.sources.len()).map(|_| Arc::default()));
}

// Extend `names`.
Expand Down

0 comments on commit cff8fde

Please sign in to comment.