Constant aho_corasick::packed::rabinkarp::NUM_BUCKETS

source ·
const NUM_BUCKETS: usize = 64;
Expand description

The number of buckets to store our patterns in. We don’t want this to be too big in order to avoid wasting memory, but we don’t want it to be too small either to avoid spending too much time confirming literals.

The number of buckets MUST be a power of two. Otherwise, determining the bucket from a hash will slow down the code considerably. Using a power of two means hash % NUM_BUCKETS can compile down to a simple and instruction.