1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Optimize: Use a hash table in compute_partition.

This reduces the execution time of gperf on large inputs by ca. 30%.

* autogen.sh (GNULIB_MODULES): Add map-c++, hash-map.
* src/keyword.h: Include <stddef.h>.
(struct KeywordExt): Add fields _undetermined_chars,
_undetermined_chars_length, _undetermined_chars_hashcode.
* src/search.cc: Include gl_map.hh, gl_hash_map.h.
(Search::prepare_asso_values): Initialize the _undetermined_chars field.
(struct EquivalenceClass): Remove the fields _undetermined_chars,
_undetermined_chars_length.
(undetermined_equals, undetermined_hashcode): New functions.
(Search::compute_partition): Initialize the _undetermined_chars* fields
of all keywords. Use a hash map instead of a loop over the equivalence
classes.
(Search::find_good_asso_values): Deallocate the _undetermined_chars field.
This commit is contained in:
Bruno Haible
2025-04-19 15:03:01 +02:00
parent 43fa5ebcb7
commit 772a63e46d
5 changed files with 118 additions and 25 deletions

View File

@@ -66,6 +66,7 @@ if test $skip_gnulib = false; then
GNULIB_MODULES='
filename
getopt-gnu
map-c++ hash-map
read-file
package-version
'