Skip to content

Commit d1e19a4

Browse files
committed
perf: ReplaceSource source
1 parent ef71210 commit d1e19a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/replace_source.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ impl Source for ReplaceSource {
165165
if rope.len() == 1 {
166166
SourceValue::String(Cow::Borrowed(rope[0]))
167167
} else {
168-
SourceValue::String(Cow::Owned(rope.join("")))
168+
let mut string = String::with_capacity(rope.iter().map(|c| c.len()).sum());
169+
for chunk in rope {
170+
string.push_str(chunk);
171+
}
172+
SourceValue::String(Cow::Owned(string))
169173
}
170174
}
171175

0 commit comments

Comments
 (0)