From: Ulya Trofimovich Date: Sun, 9 Aug 2015 19:01:52 +0000 (+0100) Subject: Use size_t to store the length of path in skeleton. X-Git-Tag: 0.15~153 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4114fe90f60c59780625007240079a22ae15e5dc;p=re2c Use size_t to store the length of path in skeleton. Though this length shouldn't actually excedd 32 bits (othewise too much data will be generated, and that is checked), it's better to use size_t and don't care about the order of checks. --- diff --git a/re2c/src/codegen/skeleton/path.cc b/re2c/src/codegen/skeleton/path.cc index ff2c6ca8..750e8aea 100644 --- a/re2c/src/codegen/skeleton/path.cc +++ b/re2c/src/codegen/skeleton/path.cc @@ -6,7 +6,7 @@ namespace re2c namespace skeleton { -Path::Path (const chars_t & cs, uint32_t l, rule_rank_t r) +Path::Path (const chars_t & cs, size_t l, rule_rank_t r) : chars (cs) , length (l) , rule (r) @@ -34,7 +34,8 @@ void Path::append (const Path * p) length = chars.size () + p->length; rule = p->rule; } - for (uint32_t i = 0; i < p->chars.size (); ++i) + const size_t sz = p->chars.size (); + for (size_t i = 0; i < sz; ++i) { chars.push_back (p->chars[i]); } diff --git a/re2c/src/codegen/skeleton/path.h b/re2c/src/codegen/skeleton/path.h index b24e20a0..9fc2cbf7 100644 --- a/re2c/src/codegen/skeleton/path.h +++ b/re2c/src/codegen/skeleton/path.h @@ -17,10 +17,10 @@ struct Path typedef std::vector chars_t; chars_t chars; - uint32_t length; + size_t length; rule_rank_t rule; - Path (const chars_t & cs, uint32_t l, rule_rank_t r); + Path (const chars_t & cs, size_t l, rule_rank_t r); void update (rule_rank_t r); void extend (rule_rank_t r, uint32_t c); void append (const Path * p);