3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-05-24 19:06:21 +00:00

Replace manual pair unpacking with structured bindings (#8197)

* Initial plan

* Apply structured bindings to enode_bool_pair usage

Replace manual unpacking of pairs with C++17 structured bindings in:
- src/ast/euf/euf_egraph.cpp
- src/smt/smt_internalizer.cpp
- src/smt/smt_context.cpp (2 locations)

This improves code readability and reduces boilerplate code.

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-01-14 19:52:01 -08:00 committed by GitHub
parent e7f9a31b25
commit 1bf463d77a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 11 deletions

View file

@ -71,9 +71,9 @@ namespace euf {
enode_bool_pair egraph::insert_table(enode* p) { enode_bool_pair egraph::insert_table(enode* p) {
TRACE(euf_verbose, tout << "insert_table " << bpp(p) << "\n"); TRACE(euf_verbose, tout << "insert_table " << bpp(p) << "\n");
//SASSERT(!m_table.contains_ptr(p)); //SASSERT(!m_table.contains_ptr(p));
auto rc = m_table.insert(p); auto [cg, comm] = m_table.insert(p);
p->m_cg = rc.first; p->m_cg = cg;
return rc; return {cg, comm};
} }
void egraph::erase_from_table(enode* p) { void egraph::erase_from_table(enode* p) {

View file

@ -653,8 +653,7 @@ namespace smt {
} }
} }
if (parent->is_cgc_enabled()) { if (parent->is_cgc_enabled()) {
enode_bool_pair pair = m_cg_table.insert(parent); auto [parent_prime, used_commutativity] = m_cg_table.insert(parent);
enode * parent_prime = pair.first;
if (parent_prime == parent) { if (parent_prime == parent) {
SASSERT(parent); SASSERT(parent);
SASSERT(parent->is_cgr()); SASSERT(parent->is_cgr());
@ -665,7 +664,6 @@ namespace smt {
parent->m_cg = parent_prime; parent->m_cg = parent_prime;
SASSERT(!m_cg_table.contains_ptr(parent)); SASSERT(!m_cg_table.contains_ptr(parent));
if (parent_prime->m_root != parent->m_root) { if (parent_prime->m_root != parent->m_root) {
bool used_commutativity = pair.second;
TRACE(cg, tout << "found new congruence: #" << parent->get_owner_id() << " = #" << parent_prime->get_owner_id() TRACE(cg, tout << "found new congruence: #" << parent->get_owner_id() << " = #" << parent_prime->get_owner_id()
<< " used_commutativity: " << used_commutativity << "\n";); << " used_commutativity: " << used_commutativity << "\n";);
push_new_congruence(parent, parent_prime, used_commutativity); push_new_congruence(parent, parent_prime, used_commutativity);
@ -972,8 +970,8 @@ namespace smt {
(parent == cg || // parent was root of the congruence class before and after the merge (parent == cg || // parent was root of the congruence class before and after the merge
!congruent(parent, cg) // parent was root of the congruence class before but not after the merge !congruent(parent, cg) // parent was root of the congruence class before but not after the merge
)) { )) {
enode_bool_pair p = m_cg_table.insert(parent); auto [parent_cg, used_commutativity] = m_cg_table.insert(parent);
parent->m_cg = p.first; parent->m_cg = parent_cg;
} }
} }
} }

View file

@ -1028,11 +1028,9 @@ namespace smt {
} }
else { else {
if (cgc_enabled) { if (cgc_enabled) {
enode_bool_pair pair = m_cg_table.insert(e); auto [e_prime, used_commutativity] = m_cg_table.insert(e);
enode * e_prime = pair.first;
if (e != e_prime) { if (e != e_prime) {
e->m_cg = e_prime; e->m_cg = e_prime;
bool used_commutativity = pair.second;
push_new_congruence(e, e_prime, used_commutativity); push_new_congruence(e, e_prime, used_commutativity);
} }
else { else {