]> granicus.if.org Git - re2c/commitdiff
Invert comparison result instead of negating its arguments.
authorUlya Trofimovich <skvadrik@gmail.com>
Tue, 27 Jun 2017 13:14:33 +0000 (14:14 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Tue, 27 Jun 2017 13:14:33 +0000 (14:14 +0100)
re2c/src/dfa/closure.cc

index 0f9ac97a3f1aa34421a56432855294298c9746ca..80caa1aa18b565f0818bb66271877473ea094807 100644 (file)
@@ -253,8 +253,8 @@ bool better(const clos_t &c1, const clos_t &c2,
                        if (redundant(t, tags)) continue;
                        const hidx_t i1 = c1.tlook, i2 = c2.tlook;
                        const tagver_t
-                               o1 = -tagpool[c1.order][t],
-                               o2 = -tagpool[c2.order][t];
+                               o1 = tagpool[c1.order][t],
+                               o2 = tagpool[c2.order][t];
                        const int32_t cmp = h.compare_histories(i1, i2, o1, o2, t, orbit(tags[t]));
                        if (cmp < 0) return false;
                        if (cmp > 0) return true;
@@ -402,9 +402,10 @@ struct cmp_posix_t
        {
                const hidx_t i1 = x->tlook, i2 = y->tlook;
                const tagver_t
-                       o1 = -tagpool[x->order][tag],
-                       o2 = -tagpool[y->order][tag];
-               return tagpool.history.compare_last_subhistories(i1, i2, o1, o2, tag, orbit) < 0;
+                       o1 = tagpool[x->order][tag],
+                       o2 = tagpool[y->order][tag];
+               // comparison result is inverted, because orders are used as offsets
+               return tagpool.history.compare_last_subhistories(i1, i2, o1, o2, tag, orbit) > 0;
        }
 };