Skip to content

Commit 28784f6

Browse files
committed
revert
1 parent bfe4f74 commit 28784f6

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

src/helpers.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,21 @@ pub fn get_map<S: StreamChunks>(
4242
&mut |source_index, source, source_content| {
4343
let source_index = source_index as usize;
4444
if sources.len() <= source_index {
45-
sources.resize(source_index + 1, "".into());
45+
sources.resize(source_index + 1, "".to_string());
4646
}
4747
sources[source_index] = source.to_string();
4848
if let Some(source_content) = source_content {
4949
if sources_content.len() <= source_index {
50-
sources_content.resize(source_index + 1, "".into());
50+
sources_content.resize(source_index + 1, "".to_string());
5151
}
52-
// TODO: avoid to_string allocation
5352
sources_content[source_index] = source_content.to_string();
5453
}
5554
},
5655
// on_name
5756
&mut |name_index, name| {
5857
let name_index = name_index as usize;
5958
if names.len() <= name_index {
60-
names.resize(name_index + 1, "".into());
59+
names.resize(name_index + 1, "".to_string());
6160
}
6261
names[name_index] = name.to_string();
6362
},
@@ -1220,7 +1219,6 @@ pub fn stream_and_get_source_and_map<'a, S: StreamChunks>(
12201219
while sources_content.len() <= source_index2 {
12211220
sources_content.push("".into());
12221221
}
1223-
// TODO: avoid allocation here
12241222
sources_content[source_index2] = source_content.to_string();
12251223
}
12261224
on_source(source_index, source, source_content);
@@ -1239,12 +1237,7 @@ pub fn stream_and_get_source_and_map<'a, S: StreamChunks>(
12391237
let map = if mappings.is_empty() {
12401238
None
12411239
} else {
1242-
Some(SourceMap::new(
1243-
mappings.to_string(),
1244-
sources,
1245-
sources_content,
1246-
names,
1247-
))
1240+
Some(SourceMap::new(mappings, sources, sources_content, names))
12481241
};
12491242
(generated_info, map)
12501243
}

src/source_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ impl PartialEq for SourceMapCell {
243243
impl Hash for SourceMapCell {
244244
fn hash<H: Hasher>(&self, state: &mut H) {
245245
match self {
246-
SourceMapCell::Static(s) => s.hash(state),
247-
SourceMapCell::Owned(owned) => owned.hash(state),
246+
SourceMapCell::Static(s) => s.hash(state),
247+
SourceMapCell::Owned(owned) => owned.hash(state),
248248
}
249249
}
250250
}
@@ -421,7 +421,7 @@ impl SourceMap {
421421
}
422422

423423
/// Set the sourcesContent field in [SourceMap].
424-
pub fn set_sources_content(&mut self, sources_content: Vec<String>) {
424+
pub fn set_sources_content<T: Into<Arc<[String]>>>(&mut self, sources_content: T) {
425425
self.ensure_owned().sources_content = sources_content.into()
426426
}
427427

src/source_map_source.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,11 @@ mod tests {
453453
}
454454

455455
test_cached!(source, |s: &dyn Source| s.source().to_string());
456-
// test_cached!(source, |s: &dyn Source| s
457-
// .map(&MapOptions::default())
458-
// .map(|m| m.into_owned()));
459-
// test_cached!(source, |s: &dyn Source| s
460-
// .map(&MapOptions {
461-
// columns: false,
462-
// final_source: true
463-
// })
464-
// .map(|m| m.into_owned()));
456+
test_cached!(source, |s: &dyn Source| s.map(&MapOptions::default()));
457+
test_cached!(source, |s: &dyn Source| s.map(&MapOptions {
458+
columns: false,
459+
final_source: true
460+
}));
465461
}
466462

467463
#[test]

0 commit comments

Comments
 (0)