diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-14 19:28:14 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-14 19:28:14 +0000 |
commit | a0fa585515445e57ece48cb7847f8a933166cacd (patch) | |
tree | 80025690249c78cd336d6a2c3f792cd99c601847 /crates | |
parent | 425c56aa52b13c010f99cb26202c00517c02f846 (diff) | |
parent | e640fa967ca9b1599c1339edfd58cbe27769808f (diff) |
Merge #7678
7678: Simplify find_crlf r=matklad a=michalmuskala
This is both simpler to read and compiles to better code: https://rust.godbolt.org/z/MxKodv
Co-authored-by: Michał Muskała <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/line_endings.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/line_endings.rs b/crates/rust-analyzer/src/line_endings.rs index 9f892f32e..bf0e255d9 100644 --- a/crates/rust-analyzer/src/line_endings.rs +++ b/crates/rust-analyzer/src/line_endings.rs | |||
@@ -46,7 +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 | src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n')) | 49 | src.windows(2).position(|it| it == b"\r\n") |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |