mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Optimize: Minimize object references in find_asso_values.
This reduces the execution time of gperf on large inputs by ca. 4%. * src/search.cc (Search::find_asso_values): Cache some values in local variables.
This commit is contained in:
@@ -1334,6 +1334,11 @@ Search::find_asso_values ()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Cache some values in local variables, for speed. */
|
||||
bool hash_includes_len = _hash_includes_len;
|
||||
bool *undetermined = step->_undetermined;
|
||||
int *asso_values = _asso_values;
|
||||
|
||||
/* Test whether these asso_values[] lead to collisions among
|
||||
the equivalence classes that should be collision-free. */
|
||||
bool has_collision = false;
|
||||
@@ -1350,12 +1355,12 @@ Search::find_asso_values ()
|
||||
the yet undetermined asso_values[]. */
|
||||
int hashcode;
|
||||
{
|
||||
int sum = _hash_includes_len ? keyword->_allchars_length : 0;
|
||||
int sum = hash_includes_len ? keyword->_allchars_length : 0;
|
||||
const unsigned int *p = keyword->_selchars;
|
||||
int i = keyword->_selchars_length;
|
||||
for (; i > 0; p++, i--)
|
||||
if (!step->_undetermined[*p])
|
||||
sum += _asso_values[*p];
|
||||
if (!undetermined[*p])
|
||||
sum += asso_values[*p];
|
||||
hashcode = sum;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user