Skip to content

Commit

Permalink
Use find in indent detection (#11650)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed May 31, 2024
1 parent 1ad5f9c commit 91a5fde
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions crates/ruff_python_codegen/src/stylist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,7 @@ fn detect_indention(tokens: &[LexResult], locator: &Locator) -> Indentation {
}
TokenKind::NonLogicalNewline => {
let line = locator.line(range.end());
let indent_index = line.char_indices().find_map(|(i, c)| {
if c.is_whitespace() {
None
} else {
Some(i)
}
});
let indent_index = line.find(|c: char| !c.is_whitespace());
if let Some(indent_index) = indent_index {
if indent_index > 0 {
let whitespace = &line[..indent_index];
Expand Down

0 comments on commit 91a5fde

Please sign in to comment.