Skip to content

Commit

Permalink
memrchr: Use a conditional instead of subtracting a complicated min
Browse files Browse the repository at this point in the history
This makes the critical calculation easier to understand.
  • Loading branch information
bluss committed Aug 24, 2016
1 parent d1ecee9 commit 8295c50
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libstd/memchr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8295c50

Please sign in to comment.