This reduces the execution time of gperf on large inputs by ca. 10%.
* src/search.cc (cmp_equiv_classes): New function.
(compute_partition): Sort the equivalence classes according to
decreasing size.
* src/search.h (Search::compute_partition): Return a 'Partition *', not
a 'EquivalenceClass *'.
(Search::count_possible_collisions, Search::unchanged_partition): Change
parameter from 'EquivalenceClass *' to 'Partition *'.
* src/search.cc (struct EquivalenceClass): Remove field _next.
(struct Partition): New type.
(struct Step): Change type of _partition from 'EquivalenceClass *' to
'Partition *'.
(Search::compute_partition): Return a 'Partition *', not a
'EquivalenceClass *'.
(delete_partition): Update.
(Search::count_possible_collisions, Search::unchanged_partition): Change
parameter from 'EquivalenceClass *' to 'Partition *'.
(Search::find_asso_values): Update.
Storing list elements in contiguous memory means: less cache misses.
This reduces the execution time of gperf on large inputs by ca. 30%.
* src/arraylist.h: New file.
* src/arraylist.cc: New file.
* src/Makefile.in (OBJECTS): Add arraylist.$(OBJEXT).
(ARRAYLIST_H): New variable.
(arraylist.$(OBJEXT)): New rule.
(search.$(OBJEXT)): Update dependencies.
(SOURCE_FILES): Add arraylist.cc and arraylist.h.
* src/search.cc: Include arraylist.h.
(struct EquivalenceClass): An an ArrayList field. Remove the linked-list
fields. Add a constructor.
(Search::compute_partition, delete_partition): Update.
(Search::count_possible_collisions, Search::unchanged_partition,
Search::find_asso_values): Update.
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.