gperf
For instance, the option ‘-k 1,2,4,6-10,'$'’ generates a hash function that considers positions 1,2,4,6,7,8,9,10, plus the last byte in each keyword (which may be at a different position for each keyword, obviously). Keywords with length less than the indicated byte positions work properly, since selected byte positions exceeding the keyword length are simply not referenced in the hash function.
This option is not normally needed since version 2.8 of gperf
;
the default byte positions are computed depending on the keyword set,
through a search that minimizes the number of byte positions.
gperf
treats all these keywords as
part of an equivalence class and generates a perfect hash function with
multiple comparisons for duplicate keywords. It is up to you to completely
disambiguate the keywords by modifying the generated C code. However,
gperf
helps you out by organizing the output.
Using this option usually means that the generated hash function is no
longer perfect. On the other hand, it permits gperf
to work on
keyword sets that it otherwise could not handle.
gperf
jumps by random amounts.
If `generate switch' option ‘-S’ (or, equivalently, ‘%switch’) is not enabled, the maximum associated value influences the static array table size, and a larger table should decrease the time required for an unsuccessful search, at the expense of extra table space.
The default value is 1, thus the default maximum associated value about the same size as the number of keywords (for efficiency, the maximum associated value is always rounded up to a power of 2). The actual table size may vary somewhat, since this technique is essentially a heuristic.