Skip to content

Commit 053f2fc

Browse files
authored
pref: use arc to prevent copy str (#55)
1 parent ed7cb9e commit 053f2fc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/helpers.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,12 +898,12 @@ struct SourceMapLineData {
898898

899899
#[derive(Debug)]
900900
struct SourceMapLineChunk {
901-
content: Box<str>,
902-
cached: once_cell::sync::OnceCell<LineWithIndicesArray<Box<str>>>,
901+
content: ArcStr,
902+
cached: once_cell::sync::OnceCell<LineWithIndicesArray<ArcStr>>,
903903
}
904904

905905
impl SourceMapLineChunk {
906-
pub fn new(content: Box<str>) -> Self {
906+
pub fn new(content: ArcStr) -> Self {
907907
Self {
908908
content,
909909
cached: once_cell::sync::OnceCell::new(),
@@ -1142,9 +1142,7 @@ pub fn stream_chunks_of_combined_source_map(
11421142
Arc::new(
11431143
lines
11441144
.into_iter()
1145-
.map(|s| {
1146-
LineWithIndicesArray::new(s.to_string().into())
1147-
})
1145+
.map(|s| LineWithIndicesArray::new(s.into()))
11481146
.collect::<Vec<_>>(),
11491147
)
11501148
})

0 commit comments

Comments
 (0)