mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
memrchr: Use a conditional instead of subtracting a complicated min
This makes the critical calculation easier to understand.
This commit is contained in:
parent
d1ecee96bf
commit
8295c5056d
@ -209,7 +209,7 @@ mod fallback {
|
||||
let end_align = (ptr as usize + len) & (usize_bytes - 1);
|
||||
let mut offset;
|
||||
if end_align > 0 {
|
||||
offset = len - cmp::min(end_align, len);
|
||||
offset = if end_align >= len { 0 } else { len - end_align };
|
||||
if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) {
|
||||
return Some(offset + index);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user