mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Fill unused asso_values[] entries in search.cc, not in output.cc.
This commit is contained in:
@@ -109,7 +109,6 @@ main (int argc, char *argv[])
|
||||
searcher._alpha_inc,
|
||||
searcher._total_duplicates,
|
||||
searcher._alpha_size,
|
||||
searcher._occurrences,
|
||||
searcher._asso_values);
|
||||
outputter.output ();
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ Output::Output (KeywordExt_List *head, const char *struct_decl,
|
||||
int total_keys, int max_key_len, int min_key_len,
|
||||
const Positions& positions, const unsigned int *alpha_inc,
|
||||
int total_duplicates, unsigned int alpha_size,
|
||||
const int *occurrences, const int *asso_values)
|
||||
const int *asso_values)
|
||||
: _head (head), _struct_decl (struct_decl),
|
||||
_struct_decl_lineno (struct_decl_lineno), _return_type (return_type),
|
||||
_struct_tag (struct_tag),
|
||||
@@ -103,7 +103,7 @@ Output::Output (KeywordExt_List *head, const char *struct_decl,
|
||||
_max_key_len (max_key_len), _min_key_len (min_key_len),
|
||||
_key_positions (positions), _alpha_inc (alpha_inc),
|
||||
_total_duplicates (total_duplicates), _alpha_size (alpha_size),
|
||||
_occurrences (occurrences), _asso_values (asso_values)
|
||||
_asso_values (asso_values)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -492,8 +492,7 @@ Output::output_hash_function () const
|
||||
printf (",");
|
||||
if ((count % columns) == 0)
|
||||
printf ("\n ");
|
||||
printf ("%*d", field_width,
|
||||
_occurrences[count] ? _asso_values[count] : _max_hash_value + 1);
|
||||
printf ("%*d", field_width, _asso_values[count]);
|
||||
}
|
||||
|
||||
printf ("\n"
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
const unsigned int *alpha_inc,
|
||||
int total_duplicates,
|
||||
unsigned int alpha_size,
|
||||
const int *occurrences,
|
||||
const int *asso_values);
|
||||
|
||||
/* Generates the hash function and the key word recognizer function. */
|
||||
@@ -132,8 +131,6 @@ private:
|
||||
int _max_hash_value;
|
||||
/* Size of alphabet. */
|
||||
unsigned int const _alpha_size;
|
||||
/* Counts occurrences of each key set character. */
|
||||
const int * const _occurrences;
|
||||
/* Value associated with each character. */
|
||||
const int * const _asso_values;
|
||||
};
|
||||
|
||||
@@ -1477,6 +1477,21 @@ Search::optimize ()
|
||||
|
||||
/* Sorts the keyword list by hash value. */
|
||||
sort ();
|
||||
|
||||
/* Set unused asso_values[c] to max_hash_value + 1. This is not absolutely
|
||||
necessary, but speeds up the lookup function in many cases of lookup
|
||||
failure: no string comparison is needed once the hash value of a string
|
||||
is larger than the hash value of any keyword. */
|
||||
int max_hash_value;
|
||||
{
|
||||
KeywordExt_List *temp;
|
||||
for (temp = _head; temp->rest(); temp = temp->rest())
|
||||
;
|
||||
max_hash_value = temp->first()->_hash_value;
|
||||
}
|
||||
for (unsigned int c = 0; c < _alpha_size; c++)
|
||||
if (_occurrences[c] == 0)
|
||||
_asso_values[c] = max_hash_value + 1;
|
||||
}
|
||||
|
||||
/* Prints out some diagnostics upon completion. */
|
||||
|
||||
Reference in New Issue
Block a user