]> granicus.if.org Git - re2c/commitdiff
There's no use in looping twice when tracing default paths.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 18 May 2016 15:57:40 +0000 (16:57 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 18 May 2016 15:57:40 +0000 (16:57 +0100)
re2c/src/ir/skeleton/control_flow.cc
re2c/test/input2.b.c
re2c/test/input2.c
re2c/test/input3.c

index 36a0956d1987f11ea08742d79cec91601fbb9d12..7124c1a7106dd86c0a9c15346ec82c53974eb2fb 100644 (file)
@@ -1,3 +1,4 @@
+#include <valarray>
 #include <vector>
 
 #include "src/conf/warn.h"
@@ -19,7 +20,7 @@ typedef u32lim_t<1024> ucf_size_t; // ~1Kb
 // UCF stands for 'undefined control flow'
 struct ucf_t
 {
-       std::vector<uint8_t> loops;
+       std::valarray<bool> loops;
        std::vector<path_t> paths;
        path_t prefix;
        ucf_size_t size;
@@ -36,7 +37,7 @@ static void naked_paths(
        size_t i)
 {
        const Node &node = skel.nodes[i];
-       uint8_t &loop = ucf.loops[i];
+       bool &loop = ucf.loops[i];
        path_t &prefix = ucf.prefix;
        ucf_size_t &size = ucf.size;
 
@@ -45,8 +46,8 @@ static void naked_paths(
        } else if (node.end()) {
                ucf.paths.push_back(prefix);
                size = size + ucf_size_t::from64(prefix.len());
-       } else if (loop < 2) {
-               local_inc _(loop);
+       } else if (!loop) {
+               loop = true;
                Node::arcsets_t::const_iterator
                        arc = node.arcsets.begin(),
                        end = node.arcsets.end();
index a4cf343a8d814e67417b4de85e1ed143256cd044..f04e954380f805c1bcac5aa5cc53cd9aac14b1bd 100644 (file)
@@ -65,7 +65,5 @@ yy3:
 re2c: warning: line 5: control flow is undefined for strings that match 
        '[\x0-\x60\x62-\xFF]'
        '\x61 [\x0-\x60\x63-\xFF]'
-       '\x61 \x61 [\x0-\x60\x63-\xFF]'
        '\x61 \x62 [\x0-\x61\x63-\xFF]'
-       '\x61 \x61 \x62 [\x0-\x61\x63-\xFF]'
 , use default rule '*' [-Wundefined-control-flow]
index 4304bc3b95f4532fe1b602660c57fa087cd2ae2c..c93767acf7a99e0849078236d5695039a430a524 100644 (file)
@@ -37,7 +37,5 @@ yy6:
 re2c: warning: line 5: control flow is undefined for strings that match 
        '[\x0-\x60\x62-\xFF]'
        '\x61 [\x0-\x60\x63-\xFF]'
-       '\x61 \x61 [\x0-\x60\x63-\xFF]'
        '\x61 \x62 [\x0-\x61\x63-\xFF]'
-       '\x61 \x61 \x62 [\x0-\x61\x63-\xFF]'
 , use default rule '*' [-Wundefined-control-flow]
index f3871c1dd417778d7a3b982d7dadd08d68a6994a..163aeee52d6b989e7dc3c523c16af315af3cd946 100644 (file)
@@ -37,7 +37,5 @@ yy6:
 re2c: warning: line 5: control flow is undefined for strings that match 
        '[\x0-\x60\x62-\xFF]'
        '\x61 [\x0-\x60\x63-\xFF]'
-       '\x61 \x61 [\x0-\x60\x63-\xFF]'
        '\x61 \x62 [\x0-\x61\x63-\xFF]'
-       '\x61 \x61 \x62 [\x0-\x61\x63-\xFF]'
 , use default rule '*' [-Wundefined-control-flow]