]> granicus.if.org Git - re2c/commitdiff
Yet another speedup in determinization (early exit when comparing history with itself).
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 7 Feb 2019 22:40:18 +0000 (22:40 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 7 Feb 2019 22:49:34 +0000 (22:49 +0000)
re2c/src/dfa/tag_history.h

index cc666328662d6a2d0399f89b4d7449931c37183a..04c420d6d2a5be1f3d100cfc20838691ea0591c2 100644 (file)
@@ -71,12 +71,14 @@ tagver_t tag_history_t::last(hidx_t i, size_t t) const
 
 int32_t tag_history_t::compare_reversed(hidx_t x, hidx_t y, size_t t) const
 {
+    if (x == y) return 0;
+
     // compare in reverse, from tail to head: direction makes
     // no difference when comparing for exact coincidence
     for (;;) {
         for (; x != HROOT && tag(x) != t; x = pred(x));
         for (; y != HROOT && tag(y) != t; y = pred(y));
-        if (x == HROOT && y == HROOT) return 0;
+        if (x == y) return 0;
         if (x == HROOT) return -1;
         if (y == HROOT) return 1;
         if (elem(x) > elem(y)) return -1;