From 6fcb6d8a484ebc315a4fb87906390d3dc7014293 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:54:55 -0500 Subject: [PATCH] `refactor`: `template` - cache comparison result --- src/cmd/template.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/template.rs b/src/cmd/template.rs index 2b04fcb71..f97be5616 100644 --- a/src/cmd/template.rs +++ b/src/cmd/template.rs @@ -189,8 +189,10 @@ pub fn run(argv: &[&str]) -> CliResult<()> { let mut row_no = 0_u64; let mut rowcount = 0; + let use_rowno_filename = args.flag_outfilename == QSV_ROWNO; + // Create filename environment once if needed - let filename_env = if output_to_dir && args.flag_outfilename != QSV_ROWNO { + let filename_env = if output_to_dir && !use_rowno_filename { let mut env = Environment::new(); minijinja_contrib::add_to_environment(&mut env); env.set_unknown_method_callback(unknown_method_callback); @@ -313,7 +315,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { .unwrap_or_else(|_| "RENDERING ERROR".to_owned()); if output_to_dir { - let outfilename = if args.flag_outfilename == QSV_ROWNO { + let outfilename = if use_rowno_filename { // Pad row number with required number of leading zeroes format!("{row_number:0width$}.txt") } else {