Skip to content

Commit 0e0fb81

Browse files
bors[bot]Veetaha
andauthored
Merge #5104
5104: Simplify r=matklad a=Veetaha Co-authored-by: Veetaha <[email protected]>
2 parents 513924a + 39a58ed commit 0e0fb81

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

crates/rust-analyzer/src/line_endings.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,7 @@ impl LineEndings {
4646
return (src, LineEndings::Dos);
4747

4848
fn find_crlf(src: &[u8]) -> Option<usize> {
49-
let mut search_idx = 0;
50-
while let Some(idx) = find_cr(&src[search_idx..]) {
51-
if src[search_idx..].get(idx + 1) != Some(&b'\n') {
52-
search_idx += idx + 1;
53-
continue;
54-
}
55-
return Some(search_idx + idx);
56-
}
57-
None
58-
}
59-
60-
fn find_cr(src: &[u8]) -> Option<usize> {
61-
src.iter().enumerate().find_map(|(idx, &b)| if b == b'\r' { Some(idx) } else { None })
49+
src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n'))
6250
}
6351
}
6452
}

0 commit comments

Comments
 (0)