From: Ulya Trofimovich Date: Wed, 25 Nov 2015 06:49:29 +0000 (+0000) Subject: Substitute template class with non-template, as only one specialization is used. X-Git-Tag: 0.15.3~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4d2cc041940a610a2cccca5430c9b4e40ba6aa7;p=re2c Substitute template class with non-template, as only one specialization is used. --- diff --git a/re2c/src/codegen/skeleton/generate_data.cc b/re2c/src/codegen/skeleton/generate_data.cc index 34cd3c40..b62e18a9 100644 --- a/re2c/src/codegen/skeleton/generate_data.cc +++ b/re2c/src/codegen/skeleton/generate_data.cc @@ -9,7 +9,7 @@ namespace re2c { template - static Node::covers_t cover_one (FILE * input, FILE * keys, const multipath_t & path); + static Node::covers_t cover_one (FILE * input, FILE * keys, const path_t & path); /* * note [generating skeleton path cover] @@ -41,12 +41,12 @@ template * */ template - Node::covers_t Node::cover (multipath_t & prefix, FILE * input, FILE * keys) + Node::covers_t Node::cover (path_t & prefix, FILE * input, FILE * keys) { covers_t size = covers_t::from32(0u); if (end () && suffix == NULL) { - suffix = new multipath_t (rule, ctx); + suffix = new path_t (rule, ctx); } if (suffix != NULL) { @@ -58,7 +58,7 @@ template local_inc _ (loop); for (arcs_t::iterator i = arcs.begin (); i != arcs.end (); ++i) { - multipath_t new_prefix = prefix; + path_t new_prefix = prefix; new_prefix.extend (i->first->rule, i->first->ctx, &i->second); size = size + i->first->cover (new_prefix, input, keys); if (size.overflow ()) @@ -67,7 +67,7 @@ template } if (i->first->suffix != NULL && suffix == NULL) { - suffix = new multipath_t (rule, ctx); + suffix = new path_t (rule, ctx); suffix->extend (i->first->rule, i->first->ctx, &i->second); suffix->append (i->first->suffix); } @@ -79,7 +79,7 @@ template template void Skeleton::generate_paths_cunit_key (FILE * input, FILE * keys) { - multipath_t prefix (nodes->rule, nodes->ctx); + path_t prefix (nodes->rule, nodes->ctx); if (nodes->cover (prefix, input, keys).overflow ()) { warning @@ -154,7 +154,7 @@ template } template - static Node::covers_t cover_one (FILE * input, FILE * keys, const multipath_t & path) + static Node::covers_t cover_one (FILE * input, FILE * keys, const path_t & path) { const size_t len = path.len (); diff --git a/re2c/src/codegen/skeleton/path.h b/re2c/src/codegen/skeleton/path.h index d31ff9b3..66ef599f 100644 --- a/re2c/src/codegen/skeleton/path.h +++ b/re2c/src/codegen/skeleton/path.h @@ -28,10 +28,13 @@ struct rule_t } }; -template -class generic_path_t +class path_t { - std::vector arcs; +public: + typedef std::vector arc_t; + +private: + std::vector arcs; rule_t rule; size_t rule_pos; @@ -40,7 +43,7 @@ class generic_path_t size_t ctx_pos; public: - explicit generic_path_t (rule_t r, bool c) + explicit path_t (rule_t r, bool c) : arcs () , rule (r) , rule_pos (0) @@ -61,11 +64,11 @@ public: { return rule.rank; } - const arc_t & operator [] (size_t i) const + const arc_t * operator [] (size_t i) const { return arcs[i]; } - void extend (rule_t r, bool c, const arc_t & a) + void extend (rule_t r, bool c, const arc_t * a) { arcs.push_back (a); if (!r.rank.is_none ()) @@ -79,7 +82,7 @@ public: ctx_pos = arcs.size (); } } - void append (const generic_path_t * p) + void append (const path_t * p) { if (!p->rule.rank.is_none ()) { @@ -95,11 +98,6 @@ public: } }; -typedef generic_path_t path_t; - -typedef std::vector multiarc_t; -typedef generic_path_t multipath_t; - } // namespace re2c #endif // _RE2C_CODEGEN_SKELETON_PATH_ diff --git a/re2c/src/codegen/skeleton/skeleton.h b/re2c/src/codegen/skeleton/skeleton.h index 96142311..979491f6 100644 --- a/re2c/src/codegen/skeleton/skeleton.h +++ b/re2c/src/codegen/skeleton/skeleton.h @@ -52,7 +52,7 @@ struct Node typedef u32lim_t<1024 * 1024 * 64> nakeds_t; // ~64Mb typedef std::map s2n_map; - typedef std::map arcs_t; + typedef std::map arcs_t; typedef std::map arcsets_t; typedef local_increment_t local_inc; @@ -79,7 +79,7 @@ struct Node std::set reachable; // path to end node (for constructing path cover) - multipath_t * suffix; + path_t * suffix; Node (); void init (const State * s, const s2n_map & s2n); @@ -88,7 +88,7 @@ struct Node void calc_dist (); void calc_reachable (); template - covers_t cover (multipath_t & prefix, FILE * input, FILE * keys); + covers_t cover (path_t & prefix, FILE * input, FILE * keys); nakeds_t naked_ways (const way_t & prefix, std::vector & ways); FORBID_COPY (Node);