mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
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 <michal@muskala.eu>
This commit is contained in:
@@ -46,7 +46,7 @@ pub(crate) fn normalize(src: String) -> (String, 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user