From b2aeb071370afeefceec4d21734e801837dd72e4 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 4 Mar 2023 21:41:24 +0100 Subject: [PATCH] Use trimmed instead of line for performance --- src/tools/tidy/src/style.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index e3f98f42d7d..75a4586cb7f 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -431,14 +431,14 @@ fn skip(path: &Path) -> bool { } if filename.ends_with(".ftl") { - let line_backticks = line.chars().filter(|ch| *ch == '`').count(); + let line_backticks = trimmed.chars().filter(|ch| *ch == '`').count(); if line_backticks % 2 == 1 { suppressible_tidy_err!(err, skip_odd_backticks, "odd number of backticks"); } - } else if line.contains("//") { + } else if trimmed.contains("//") { let (start_line, mut backtick_count) = comment_block.unwrap_or((i + 1, 0)); - let line_backticks = line.chars().filter(|ch| *ch == '`').count(); - let comment_text = line.split("//").nth(1).unwrap(); + let line_backticks = trimmed.chars().filter(|ch| *ch == '`').count(); + let comment_text = trimmed.split("//").nth(1).unwrap(); // This check ensures that we don't lint for code that has `//` in a string literal if line_backticks % 2 == 1 { backtick_count += comment_text.chars().filter(|ch| *ch == '`').count();