mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 18:15:07 +03:00
core: Make TwoWaySearcher reset its prefix memory when shifting by byteset
Closes #16878.
This commit is contained in:
@@ -479,6 +479,9 @@ fn next(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) -> Option<
|
||||
((haystack[self.position + needle.len() - 1] & 0x3f)
|
||||
as uint)) & 1 == 0 {
|
||||
self.position += needle.len();
|
||||
if !long_period {
|
||||
self.memory = 0;
|
||||
}
|
||||
continue 'search;
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user