aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/line_endings.rs14
1 files changed, 1 insertions, 13 deletions
diff --git a/crates/rust-analyzer/src/line_endings.rs b/crates/rust-analyzer/src/line_endings.rs
index 7e6db954e..9f892f32e 100644
--- a/crates/rust-analyzer/src/line_endings.rs
+++ b/crates/rust-analyzer/src/line_endings.rs
@@ -46,19 +46,7 @@ impl LineEndings {
46 return (src, LineEndings::Dos); 46 return (src, LineEndings::Dos);
47 47
48 fn find_crlf(src: &[u8]) -> Option<usize> { 48 fn find_crlf(src: &[u8]) -> Option<usize> {
49 let mut search_idx = 0; 49 src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n'))
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 })
62 } 50 }
63 } 51 }
64} 52}