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

Improve the speed of the positions search.

This commit is contained in:
Bruno Haible
2018-09-08 16:03:27 +02:00
parent 947854520b
commit 24f492fd8d
2 changed files with 11 additions and 2 deletions

View File

@@ -1,3 +1,10 @@
2018-09-08 Bruno Haible <bruno@clisp.org>
Improve the speed of the positions search.
Reported by Frank Wojcik <frankw@touristinresidence.com> in
<https://savannah.gnu.org/patch/?9562>.
* src/search.cc (Search::find_positions): Double the speed of step 4.
2018-09-08 Bruno Haible <bruno@clisp.org> 2018-09-08 Bruno Haible <bruno@clisp.org>
Really prefer more efficient hash functions over less efficient ones. Really prefer more efficient hash functions over less efficient ones.

View File

@@ -413,11 +413,13 @@ Search::find_positions ()
Positions best; Positions best;
unsigned int best_duplicates_count = UINT_MAX; unsigned int best_duplicates_count = UINT_MAX;
/* Loop over all pairs { i1, i2 } of currently selected positions.
W.l.o.g. we can assume i1 > i2. */
for (int i1 = imax; i1 >= -1; i1--) for (int i1 = imax; i1 >= -1; i1--)
if (current.contains (i1) && !mandatory.contains (i1)) if (current.contains (i1) && !mandatory.contains (i1))
{ {
for (int i2 = imax; i2 >= -1; i2--) for (int i2 = i1 - 1; i2 >= -1; i2--)
if (current.contains (i2) && !mandatory.contains (i2) && i2 != i1) if (current.contains (i2) && !mandatory.contains (i2))
{ {
for (int i3 = imax; i3 >= -1; i3--) for (int i3 = imax; i3 >= -1; i3--)
if (!current.contains (i3)) if (!current.contains (i3))