From 4114fe90f60c59780625007240079a22ae15e5dc Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sun, 9 Aug 2015 20:01:52 +0100 Subject: [PATCH] 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. --- re2c/src/codegen/skeleton/path.cc | 5 +++-- re2c/src/codegen/skeleton/path.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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); -- 2.40.0