mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 22:24:14 +00:00
Simplify
This commit is contained in:
parent
513924a7e0
commit
39a58ed19a
1 changed files with 1 additions and 13 deletions
|
@ -46,19 +46,7 @@ impl LineEndings {
|
||||||
return (src, LineEndings::Dos);
|
return (src, LineEndings::Dos);
|
||||||
|
|
||||||
fn find_crlf(src: &[u8]) -> Option<usize> {
|
fn find_crlf(src: &[u8]) -> Option<usize> {
|
||||||
let mut search_idx = 0;
|
src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n'))
|
||||||
while let Some(idx) = find_cr(&src[search_idx..]) {
|
|
||||||
if src[search_idx..].get(idx + 1) != Some(&b'\n') {
|
|
||||||
search_idx += idx + 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return Some(search_idx + idx);
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_cr(src: &[u8]) -> Option<usize> {
|
|
||||||
src.iter().enumerate().find_map(|(idx, &b)| if b == b'\r' { Some(idx) } else { None })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue