Skip to content

Commit

Permalink
core: Make TwoWaySearcher reset its prefix memory when shifting by by…
Browse files Browse the repository at this point in the history
…teset

Closes #16878.
  • Loading branch information
nham committed Sep 2, 2014
1 parent 0bdac78 commit e9db8ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libcore/str.rs
Expand Up @@ -479,6 +479,9 @@ impl TwoWaySearcher {
((haystack[self.position + needle.len() - 1] & 0x3f)
as uint)) & 1 == 0 {
self.position += needle.len();
if !long_period {
self.memory = 0;
}
continue 'search;
}

Expand Down
6 changes: 6 additions & 0 deletions src/libcoretest/str.rs
Expand Up @@ -26,6 +26,12 @@ fn strslice_issue_16589() {
check_contains_all_substrings("012345678901234567890123456789bcdabcdabcd");
}

#[test]
fn strslice_issue_16878() {
assert!(!"1234567ah012345678901ah".contains("hah"));
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
}


#[test]
fn test_strslice_contains() {
Expand Down

0 comments on commit e9db8ad

Please sign in to comment.