Skip to content

Commit 8295c50

Browse files
committed
memrchr: Use a conditional instead of subtracting a complicated min
This makes the critical calculation easier to understand.
1 parent d1ecee9 commit 8295c50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/memchr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ mod fallback {
209209
let end_align = (ptr as usize + len) & (usize_bytes - 1);
210210
let mut offset;
211211
if end_align > 0 {
212-
offset = len - cmp::min(end_align, len);
212+
offset = if end_align >= len { 0 } else { len - end_align };
213213
if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) {
214214
return Some(offset + index);
215215
}

0 commit comments

Comments
 (0)