From: Ulya Trofimovich Date: Wed, 8 Apr 2015 15:43:16 +0000 (+0100) Subject: Code cleanup. X-Git-Tag: 0.15~307 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fec99026298d90d622fcf80b44179f6c757211c4;p=re2c Code cleanup. --- diff --git a/re2c/skeleton.cc b/re2c/skeleton.cc index a65bc702..5f1840c0 100644 --- a/re2c/skeleton.cc +++ b/re2c/skeleton.cc @@ -39,9 +39,7 @@ Skeleton::~Skeleton () unsigned long count_data (SkeletonState * s, unsigned long count) { - const bool is_default = s == NULL; - const bool is_final = !is_default && s->go.size () == 1 && s->go.begin ()->first == NULL; - if (is_final || is_default) + if (is_final (s) || is_default (s)) { return count; } @@ -74,9 +72,7 @@ unsigned long Skeleton::count () void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector & xs, std::vector & ys) { - const bool is_default = s == NULL; - const bool is_final = !is_default && s->go.size () == 1 && s->go.begin ()->first == NULL; - if (is_final || is_default) + if (is_final (s) || is_default (s)) { for (uint i = 0; i < xs.size (); ++i) { @@ -88,10 +84,10 @@ void generate_data (DataFile & o, uint ind, SkeletonState * s, const std::vector } o.file << "\n"; const uint processed = xs[i].chars.size (); - const uint consumed = is_final + const uint consumed = is_final (s) ? xs[i].chars.size () : xs[i].length; - const uint rule = is_final + const uint rule = is_final (s) ? s->rule : xs[i].rule; ys.push_back (Result (processed, consumed, rule)); diff --git a/re2c/skeleton.h b/re2c/skeleton.h index f8403be4..d0b1256e 100644 --- a/re2c/skeleton.h +++ b/re2c/skeleton.h @@ -18,6 +18,18 @@ struct SkeletonState bool visited; }; +inline bool is_default (SkeletonState * s) +{ + return s == NULL; +} + +inline bool is_final (SkeletonState * s) +{ + return s != NULL + && s->go.size () == 1 + && s->go.begin ()->first == NULL; +} + struct Prefix { std::vector chars;