From 389b55c647da265a9ed68cffe7cbb6f93b6b7e99 Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 1 May 2024 15:21:36 +0300 Subject: [PATCH] refactor bool to void setDistinctTops setDistinctRoseTops setDistinctSuffixTops --- src/rose/rose_build_merge.cpp | 18 +++++++++--------- src/rose/rose_build_merge.h | 2 +- src/rose/rose_build_role_aliasing.cpp | 7 +------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/rose/rose_build_merge.cpp b/src/rose/rose_build_merge.cpp index c0df5765..21093a81 100644 --- a/src/rose/rose_build_merge.cpp +++ b/src/rose/rose_build_merge.cpp @@ -1687,7 +1687,7 @@ void replaceTops(NGHolder &h, const map &top_mapping) { } static -bool setDistinctTops(NGHolder &h1, const NGHolder &h2, +void setDistinctTops(NGHolder &h1, const NGHolder &h2, map &top_mapping) { flat_set tops1 = getTops(h1), tops2 = getTops(h2); @@ -1697,7 +1697,7 @@ bool setDistinctTops(NGHolder &h1, const NGHolder &h2, // If our tops don't intersect, we're OK to merge with no changes. if (!has_intersection(tops1, tops2)) { DEBUG_PRINTF("tops don't intersect\n"); - return true; + return ; } // Otherwise, we have to renumber the tops in h1 so that they don't overlap @@ -1712,17 +1712,17 @@ bool setDistinctTops(NGHolder &h1, const NGHolder &h2, } replaceTops(h1, top_mapping); - return true; + return ; } -bool setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, +void setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, const deque &verts1) { map top_mapping; setDistinctTops(h1, h2, top_mapping); if (top_mapping.empty()) { - return true; // No remapping necessary. + return ; // No remapping necessary. } for (auto v : verts1) { @@ -1740,17 +1740,17 @@ bool setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, } } - return true; + return ; } static -bool setDistinctSuffixTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, +void setDistinctSuffixTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, const deque &verts1) { map top_mapping; setDistinctTops(h1, h2, top_mapping); if (top_mapping.empty()) { - return true; // No remapping necessary. + return ; // No remapping necessary. } for (auto v : verts1) { @@ -1760,7 +1760,7 @@ bool setDistinctSuffixTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, g[v].suffix.top = top_mapping[t]; } - return true; + return ; } /** \brief Estimate the number of accel states in the given graph when built as diff --git a/src/rose/rose_build_merge.h b/src/rose/rose_build_merge.h index 6de6c778..e93a977f 100644 --- a/src/rose/rose_build_merge.h +++ b/src/rose/rose_build_merge.h @@ -62,7 +62,7 @@ bool mergeableRoseVertices(const RoseBuildImpl &tbi, RoseVertex u, bool mergeableRoseVertices(const RoseBuildImpl &tbi, const std::set &v1, const std::set &v2); -bool setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, +void setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2, const std::deque &verts1); } // namespace ue2 diff --git a/src/rose/rose_build_role_aliasing.cpp b/src/rose/rose_build_role_aliasing.cpp index 2888b9a0..39721d6f 100644 --- a/src/rose/rose_build_role_aliasing.cpp +++ b/src/rose/rose_build_role_aliasing.cpp @@ -1294,12 +1294,7 @@ bool attemptRoseGraphMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a, DEBUG_PRINTF("victim %zu states\n", num_vertices(*a_h)); DEBUG_PRINTF("winner %zu states\n", num_vertices(*b_h)); - - if (!setDistinctRoseTops(g, victim, *b_h, deque(1, a))) { - assert(roseHasTops(build, a)); - assert(roseHasTops(build, b)); - return false; - } + setDistinctRoseTops(g, victim, *b_h, deque(1, a)); assert(victim.kind == b_h->kind); assert(!generates_callbacks(*b_h));