We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 513924a + 39a58ed commit 0e0fb81Copy full SHA for 0e0fb81
crates/rust-analyzer/src/line_endings.rs
@@ -46,19 +46,7 @@ impl LineEndings {
46
return (src, LineEndings::Dos);
47
48
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 })
+ src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n'))
62
}
63
64
0 commit comments