Skip to content

Commit

Permalink
Remove unneeded saturating_add
Browse files Browse the repository at this point in the history
  • Loading branch information
tbu- committed Mar 10, 2015
1 parent 1cc8b6e commit 5199a70
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,10 @@ impl<'a> Iterator for Chars<'a> {
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let (len, _) = self.iter.size_hint();
(len.saturating_add(3) / 4, Some(len))
// `(len + 3)` can't overflow, because we know that the `slice::Iter`
// belongs to a slice in memory which has a maximum length of
// `isize::MAX` (that's well below `usize::MAX`).
((len + 3) / 4, Some(len))
}
}

Expand Down

0 comments on commit 5199a70

Please sign in to comment.