Lines Matching refs:needle
3 /// This detector attempts to pick out two bytes in a needle that are predicted
12 /// needle to reduce space usage. This means that rare byte occurring after the
13 /// first 255 bytes in a needle will never be used.
16 /// The leftmost offset of the rarest byte in the needle, according to
18 /// rare1i <= i for all i where needle[i] == needle[rare1i].
20 /// The leftmost offset of the second rarest byte in the needle, according
22 /// rare2i <= i for all i where needle[i] == needle[rare2i].
31 /// byte needle is handled specially by memchr itself, rare2i generally
38 /// Create a new pair of rare needle bytes with the given offsets. This is
46 /// needle.
47 pub(crate) fn forward(needle: &[u8]) -> RareNeedleBytes {
48 if needle.len() <= 1 || needle.len() > core::u8::MAX as usize {
53 // some rare bytes from the first 255 bytes of the needle.
63 let (mut rare1, mut rare1i) = (needle[0], 0);
64 let (mut rare2, mut rare2i) = (needle[1], 1);
69 for (i, &b) in needle.iter().enumerate().skip(2) {
88 /// Return the rare bytes in the given needle in the forward direction.
89 /// The needle given must be the same one given to the RareNeedleBytes
91 pub(crate) fn as_rare_bytes(&self, needle: &[u8]) -> (u8, u8) {
92 (needle[self.rare1i as usize], needle[self.rare2i as usize])
124 /// more frequency the byte is predicted to be. The needle given must be
126 pub(crate) fn as_ranks(&self, needle: &[u8]) -> (usize, usize) {
127 let (b1, b2) = self.as_rare_bytes(needle);