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

28
lib/.gitignore vendored
View File

@@ -5,12 +5,19 @@
/alloca.in.h
/arg-nonnull.h
/assert.in.h
/attribute.h
/basename-lgpl.c
/basename-lgpl.h
/c++defs.h
/cloexec.c
/cloexec.h
/close.c
/dup2.c
/errno.in.h
/error.c
/error.in.h
/exitfail.c
/exitfail.h
/fcntl.c
/fcntl.in.h
/fd-hook.c
@@ -31,9 +38,22 @@
/getopt.in.h
/getopt1.c
/getopt_int.h
/getprogname.c
/getprogname.h
/gettext.h
/gl_anyhash1.h
/gl_anyhash2.h
/gl_anyhash_primes.h
/gl_hash_map.c
/gl_hash_map.h
/gl_map.c
/gl_map.h
/gl_map.hh
/gl_xmap.c
/gl_xmap.h
/idx.h
/intprops-internal.h
/intprops.h
/inttypes.in.h
/limits.in.h
/lseek.c
@@ -51,6 +71,7 @@
/read-file.c
/read-file.h
/realloc.c
/size_max.h
/stat-time.c
/stat-time.h
/stat-w32.c
@@ -65,6 +86,9 @@
/stdio.in.h
/stdlib.c
/stdlib.in.h
/strerror-override.c
/strerror-override.h
/strerror.c
/string.in.h
/sys_stat.in.h
/sys_types.in.h
@@ -74,7 +98,11 @@
/verify.h
/warn-on-use.h
/wchar.in.h
/xalloc-die.c
/xalloc-oversized.h
/xalloc.h
/xsize.c
/xsize.h
# Files generated by the autotools:
/aclocal.m4