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
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

5 comments on commit 259930e

@bors
Copy link
Contributor

@bors bors commented on 259930e Sep 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at tbu-@259930e

@bors
Copy link
Contributor

@bors bors commented on 259930e Sep 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging tbu-/rust/pr_strfindoverflow2 = 259930e into auto

@bors
Copy link
Contributor

@bors bors commented on 259930e Sep 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbu-/rust/pr_strfindoverflow2 = 259930e merged ok, testing candidate = 21d1f4d

@bors
Copy link
Contributor

@bors bors commented on 259930e Sep 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 259930e Sep 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 21d1f4d

Please sign in to comment.