summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2018-09-08 16:03:27 +0200
committerBruno Haible <bruno@clisp.org>2018-09-08 16:08:09 +0200
commit24f492fd8de73ea9c30e8820da3d7ac6fdda194e (patch)
tree6654a6c3672eb465ccb77e2cdab37001954f7068
parent947854520be07af4256f7b71956aeb83dcbb149c (diff)
downloadgperf-24f492fd8de73ea9c30e8820da3d7ac6fdda194e.tar.gz
Improve the speed of the positions search.
-rw-r--r--ChangeLog7
-rw-r--r--src/search.cc6
2 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d1e00a6..16fd502 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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))