diff options
| author | est31 <MTest31@outlook.com> | 2023-03-04 21:41:24 +0100 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2023-03-11 20:43:04 +0100 |
| commit | b2aeb071370afeefceec4d21734e801837dd72e4 (patch) | |
| tree | 5a409995cc1f8a1ceb0c952d27cc7db58ba1c4a7 | |
| parent | 3a20d52694c9a293d2fbf1aa7cc1c1643b3e30ec (diff) | |
| download | rust-b2aeb071370afeefceec4d21734e801837dd72e4.tar.gz rust-b2aeb071370afeefceec4d21734e801837dd72e4.zip | |
Use trimmed instead of line for performance
| -rw-r--r-- | src/tools/tidy/src/style.rs | 8 |
1 files 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 @@ pub fn check(path: &Path, bad: &mut 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(); |
