aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-06-27 23:30:45 +0100
committerVeetaha <[email protected]>2020-06-27 23:30:45 +0100
commit39a58ed19af2fd4c27336f7a1f1510cda14dd959 (patch)
tree0c098f1fa876172f3617d099f66c76a439907de9 /crates
parent513924a7e01ef81a03869249c902daf148439736 (diff)
Simplify
Diffstat (limited to 'crates')
-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}