1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-11-29 04:07:32 +03:00

perf(test): don't create regex inside a loop (#937)

This commit is contained in:
Paul Campbell 2024-10-29 06:46:58 +00:00 committed by GitHub
parent a9b26901e3
commit 0fabf22c52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -266,6 +266,11 @@ 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,
@ -273,11 +278,7 @@ fn generate_changelog() -> Result<()> {
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();