Skip to content

Commit

Permalink
Document why core::str::Searcher::new doesn't overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tbu- committed Sep 12, 2014
1 parent 22e749d commit 259930e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ enum Searcher {
impl Searcher {
fn new(haystack: &[u8], needle: &[u8]) -> Searcher {
// FIXME: Tune this.
// FIXME(#16715): This unsigned integer addition will probably not
// overflow because that would mean that the memory almost solely
// consists of the needle. Needs #16715 to be formally fixed.
if needle.len() + 20 > haystack.len() {
Naive(NaiveSearcher::new())
} else {
Expand Down

0 comments on commit 259930e

Please sign in to comment.