diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-28 02:04:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-28 02:04:54 +0100 |
commit | 0e0fb81f14c19252121985638bed8811ec51fa39 (patch) | |
tree | 0c098f1fa876172f3617d099f66c76a439907de9 | |
parent | 513924a7e01ef81a03869249c902daf148439736 (diff) | |
parent | 39a58ed19af2fd4c27336f7a1f1510cda14dd959 (diff) |
Merge #5104
5104: Simplify r=matklad a=Veetaha
Co-authored-by: Veetaha <[email protected]>
-rw-r--r-- | crates/rust-analyzer/src/line_endings.rs | 14 |
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 | } |