Skip to content

Commit eca5233

Browse files
authored
perf: do not allocate if replacements is empty (#126)
1 parent a7e91dd commit eca5233

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/replace_source.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ impl<T: Source + Hash + PartialEq + Eq + 'static> Source for ReplaceSource<T> {
175175
// mut_string_push_str is faster that vec join
176176
// concatenate strings benchmark, see https://github.com/hoodie/concatenation_benchmarks-rs
177177
let replacements = self.replacements.lock().unwrap();
178+
if replacements.is_empty() {
179+
return inner_source_code;
180+
}
178181
let max_len = replacements
179182
.iter()
180183
.map(|replacement| replacement.content.len())

0 commit comments

Comments
 (0)