Skip to content

Commit

Permalink
Use trimmed instead of line for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Mar 11, 2023
1 parent 3a20d52 commit b2aeb07
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tools/tidy/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b2aeb07

Please sign in to comment.