Lines Matching refs:needle
33 needle: CowBytes<'b>, field
54 pub fn forward(needle: &'b [u8]) -> TwoWay<'b> { in forward()
55 let freqy = Freqy::forward(needle); in forward()
56 if needle.is_empty() { in forward()
58 needle: CowBytes::new(needle), in forward()
65 let min_suffix = Suffix::forward(needle, SuffixKind::Minimal); in forward()
66 let max_suffix = Suffix::forward(needle, SuffixKind::Maximal); in forward()
73 let shift = Shift::forward(needle, period_lower_bound, critical_pos); in forward()
74 let needle = CowBytes::new(needle); in forward() localVariable
75 TwoWay { needle, freqy, critical_pos, shift } in forward()
80 pub fn reverse(needle: &'b [u8]) -> TwoWay<'b> { in reverse()
81 let freqy = Freqy::reverse(needle); in reverse()
82 if needle.is_empty() { in reverse()
84 needle: CowBytes::new(needle), in reverse()
91 let min_suffix = Suffix::reverse(needle, SuffixKind::Minimal); in reverse()
92 let max_suffix = Suffix::reverse(needle, SuffixKind::Maximal); in reverse()
99 let shift = Shift::reverse(needle, period_lower_bound, critical_pos); in reverse()
100 let needle = CowBytes::new(needle); in reverse() localVariable
101 TwoWay { needle, freqy, critical_pos, shift } in reverse()
118 pub fn needle(&self) -> &[u8] { in needle() method
119 self.needle.as_slice() in needle()
127 needle: self.needle.into_owned(), in into_owned()
162 if self.needle.is_empty() { in find_with()
164 } else if haystack.len() < self.needle.len() { in find_with()
166 } else if self.needle.len() == 1 { in find_with()
167 return haystack.find_byte(self.needle[0]); in find_with()
189 if self.needle.is_empty() { in rfind_with()
191 } else if haystack.len() < self.needle.len() { in rfind_with()
193 } else if self.needle.len() == 1 { in rfind_with()
194 return haystack.rfind_byte(self.needle[0]); in rfind_with()
239 let needle = self.needle.as_slice(); in find_small_imp() localVariable
242 while pos + needle.len() <= haystack.len() { in find_small_imp()
251 if pos + needle.len() > haystack.len() { in find_small_imp()
257 while i < needle.len() && needle[i] == haystack[pos + i] { in find_small_imp()
260 if i < needle.len() { in find_small_imp()
265 while j > shift && needle[j] == haystack[pos + j] { in find_small_imp()
268 if j <= shift && needle[shift] == haystack[pos + shift] { in find_small_imp()
272 shift = needle.len() - period; in find_small_imp()
300 let needle = self.needle.as_slice(); in find_large_imp() localVariable
302 while pos + needle.len() <= haystack.len() { in find_large_imp()
309 if pos + needle.len() > haystack.len() { in find_large_imp()
315 while i < needle.len() && needle[i] == haystack[pos + i] { in find_large_imp()
318 if i < needle.len() { in find_large_imp()
322 while j > 0 && needle[j] == haystack[pos + j] { in find_large_imp()
325 if j == 0 && needle[0] == haystack[pos] { in find_large_imp()
356 let needle = &*self.needle; in rfind_small_imp() localVariable
357 let nlen = needle.len(); in rfind_small_imp()
375 while i > 0 && needle[i - 1] == haystack[pos - nlen + i - 1] { in rfind_small_imp()
378 if i > 0 || needle[0] != haystack[pos - nlen] { in rfind_small_imp()
383 while j < shift && needle[j] == haystack[pos - nlen + j] { in rfind_small_imp()
418 let needle = &*self.needle; in rfind_large_imp() localVariable
419 let nlen = needle.len(); in rfind_large_imp()
435 while i > 0 && needle[i - 1] == haystack[pos - nlen + i - 1] { in rfind_large_imp()
438 if i > 0 || needle[0] != haystack[pos - nlen] { in rfind_large_imp()
442 while j < nlen && needle[j] == haystack[pos - nlen + j] { in rfind_large_imp()
499 needle: &[u8], in forward()
503 let large = cmp::max(critical_pos, needle.len() - critical_pos); in forward()
504 if critical_pos * 2 >= needle.len() { in forward()
508 let (u, v) = needle.split_at(critical_pos); in forward()
522 needle: &[u8], in reverse()
526 let large = cmp::max(critical_pos, needle.len() - critical_pos); in reverse()
527 if (needle.len() - critical_pos) * 2 >= needle.len() { in reverse()
531 let (v, u) = needle.split_at(critical_pos); in reverse()
558 fn forward(needle: &[u8], kind: SuffixKind) -> Suffix { in forward()
559 debug_assert!(!needle.is_empty()); in forward()
581 while candidate_start + offset < needle.len() { in forward()
582 let current = needle[suffix.pos + offset]; in forward()
583 let candidate = needle[candidate_start + offset]; in forward()
608 fn reverse(needle: &[u8], kind: SuffixKind) -> Suffix { in reverse()
609 debug_assert!(!needle.is_empty()); in reverse()
612 let mut suffix = Suffix { pos: needle.len(), period: 1 }; in reverse()
613 if needle.len() == 1 { in reverse()
616 let mut candidate_start = needle.len() - 1; in reverse()
620 let current = needle[suffix.pos - offset - 1]; in reverse()
621 let candidate = needle[candidate_start - offset - 1]; in reverse()
710 fn get_suffix_forward(needle: &[u8], kind: SuffixKind) -> (&[u8], usize) { in get_suffix_forward()
711 let s = Suffix::forward(needle, kind); in get_suffix_forward()
712 (&needle[s.pos..], s.period) in get_suffix_forward()
716 fn get_suffix_reverse(needle: &[u8], kind: SuffixKind) -> (&[u8], usize) { in get_suffix_reverse()
717 let s = Suffix::reverse(needle, kind); in get_suffix_reverse()
718 (&needle[..s.pos], s.period) in get_suffix_reverse()
727 fn naive_maximal_suffix_forward(needle: &[u8]) -> &[u8] { in naive_maximal_suffix_forward()
728 let mut sufs = suffixes(needle); in naive_maximal_suffix_forward()
735 fn naive_maximal_suffix_reverse(needle: &[u8]) -> Vec<u8> { in naive_maximal_suffix_reverse()
736 let mut reversed = needle.to_vec(); in naive_maximal_suffix_reverse()