Skip to content

Commit

Permalink
perf(test): don't create regex inside a loop (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
kemitix authored Oct 29, 2024
1 parent a9b2690 commit 0fabf22
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions git-cliff-core/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,19 @@ fn generate_changelog() -> Result<()> {
let template = Template::new("test", changelog_config.body.unwrap(), false)?;

writeln!(out, "{}", changelog_config.header.unwrap()).unwrap();
let text_processors = [TextProcessor {
pattern: Regex::new("<DATE>").unwrap(),
replace: Some(String::from("2023")),
replace_command: None,
}];
for release in releases {
write!(
out,
"{}",
template.render(
&release,
Option::<HashMap<&str, String>>::None.as_ref(),
&[TextProcessor {
pattern: Regex::new("<DATE>").unwrap(),
replace: Some(String::from("2023")),
replace_command: None,
}]
&text_processors
)?
)
.unwrap();
Expand Down

0 comments on commit 0fabf22

Please sign in to comment.