mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-22 12:43:36 +00:00
Simplify find_crlf
This is both simpler to read and compiles to better code: https://rust.godbolt.org/z/MxKodv
This commit is contained in:
parent
425c56aa52
commit
e640fa967c
@ -46,7 +46,7 @@ impl LineEndings {
|
||||
return (src, LineEndings::Dos);
|
||||
|
||||
fn find_crlf(src: &[u8]) -> Option<usize> {
|
||||
src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n'))
|
||||
src.windows(2).position(|it| it == b"\r\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user