diff options
author | Bruno Haible <bruno@clisp.org> | 2018-09-08 16:03:27 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2018-09-08 16:08:09 +0200 |
commit | 24f492fd8de73ea9c30e8820da3d7ac6fdda194e (patch) | |
tree | 6654a6c3672eb465ccb77e2cdab37001954f7068 | |
parent | 947854520be07af4256f7b71956aeb83dcbb149c (diff) | |
download | gperf-24f492fd8de73ea9c30e8820da3d7ac6fdda194e.tar.gz |
Improve the speed of the positions search.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/search.cc | 6 |
2 files changed, 11 insertions, 2 deletions
@@ -1,5 +1,12 @@ 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> + Really prefer more efficient hash functions over less efficient ones. Reported by Frank Wojcik <frankw@touristinresidence.com> in <https://savannah.gnu.org/patch/?9561>. diff --git a/src/search.cc b/src/search.cc index 959580f..89d912b 100644 --- a/src/search.cc +++ b/src/search.cc @@ -413,11 +413,13 @@ Search::find_positions () Positions best; 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--) if (current.contains (i1) && !mandatory.contains (i1)) { - for (int i2 = imax; i2 >= -1; i2--) - if (current.contains (i2) && !mandatory.contains (i2) && i2 != i1) + for (int i2 = i1 - 1; i2 >= -1; i2--) + if (current.contains (i2) && !mandatory.contains (i2)) { for (int i3 = imax; i3 >= -1; i3--) if (!current.contains (i3)) |