Checks if we have hit the replacement limit for the current stream/comparison.
(&mut self, dst: &[u8])
| 307 | |
| 308 | /// Checks if we have hit the replacement limit for the current stream/comparison. |
| 309 | fn hit_replacement_limit(&mut self, dst: &[u8]) -> bool { |
| 310 | if self.cursor.finder.replacement.len() > 1 { |
| 311 | // Multi-byte replacements are sufficiently rare that we can try all of them. |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | let matching_value = get_u64(self.cursor.finder.get_value_to_replace(dst)); |
| 316 | let tried_match = self.tried_matches.entry(matching_value).or_default(); |
| 317 | let replacement = get_u64(&self.cursor.finder.replacement); |
| 318 | let tried_replacement = self.tried_replacements.entry(replacement).or_default(); |
| 319 | |
| 320 | if *tried_match > MAX_ONE_BYTE_MATCHES || *tried_replacement > MAX_ONE_BYTE_REPLACEMENTS { |
| 321 | return true; |
| 322 | } |
| 323 | *tried_match += 1; |
| 324 | *tried_replacement += 1; |
| 325 | false |
| 326 | } |
| 327 | |
| 328 | fn try_exec( |
| 329 | &mut self, |
no test coverage detected