mirror of
https://github.com/Z3Prover/z3
synced 2025-08-06 19:21:22 +00:00
remove using insert_if_not_there2
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9ea1cf3c5c
commit
a884201d62
47 changed files with 172 additions and 208 deletions
|
@ -65,14 +65,14 @@ std::ostream& expr_substitution::display(std::ostream& out) {
|
|||
}
|
||||
|
||||
void expr_substitution::insert(expr * c, expr * def, proof * def_pr, expr_dependency * def_dep) {
|
||||
obj_map<expr, expr*>::obj_map_entry * entry = m_subst.insert_if_not_there2(c, nullptr);
|
||||
expr*& value = m_subst.insert_if_not_there(c, nullptr);
|
||||
SASSERT(!def_pr || to_app(m_manager.get_fact(def_pr))->get_arg(0) == c);
|
||||
SASSERT(!def_pr || to_app(m_manager.get_fact(def_pr))->get_arg(1) == def);
|
||||
if (entry->get_data().m_value == nullptr) {
|
||||
if (value == nullptr) {
|
||||
// new entry
|
||||
m_manager.inc_ref(c);
|
||||
m_manager.inc_ref(def);
|
||||
entry->get_data().m_value = def;
|
||||
value = def;
|
||||
if (proofs_enabled()) {
|
||||
SASSERT(!m_subst_pr->contains(c));
|
||||
m_subst_pr->insert(c, def_pr);
|
||||
|
@ -87,8 +87,8 @@ void expr_substitution::insert(expr * c, expr * def, proof * def_pr, expr_depend
|
|||
else {
|
||||
// replacing entry
|
||||
m_manager.inc_ref(def);
|
||||
m_manager.dec_ref(entry->get_data().m_value);
|
||||
entry->get_data().m_value = def;
|
||||
m_manager.dec_ref(value);
|
||||
value = def;
|
||||
if (proofs_enabled()) {
|
||||
obj_map<expr, proof*>::obj_map_entry * entry_pr = m_subst_pr->find_core(c);
|
||||
SASSERT(entry_pr != nullptr);
|
||||
|
|
|
@ -82,12 +82,12 @@ void macro_substitution::insert(func_decl * f, quantifier * q, proof * pr, expr_
|
|||
expr * rhs = body->get_arg(1);
|
||||
SASSERT(is_app_of(lhs, f) || is_app_of(rhs, f));
|
||||
});
|
||||
obj_map<func_decl, quantifier *>::obj_map_entry * entry = m_decl2macro.insert_if_not_there2(f, 0);
|
||||
if (entry->get_data().m_value == 0) {
|
||||
quantifier*& entry = m_decl2macro.insert_if_not_there(f, 0);
|
||||
if (entry == nullptr) {
|
||||
// new entry
|
||||
m_manager.inc_ref(f);
|
||||
m_manager.inc_ref(q);
|
||||
entry->get_data().m_value = q;
|
||||
entry = q;
|
||||
if (proofs_enabled()) {
|
||||
SASSERT(!m_decl2macro_pr->contains(f));
|
||||
m_decl2macro_pr->insert(f, pr);
|
||||
|
@ -102,8 +102,8 @@ void macro_substitution::insert(func_decl * f, quantifier * q, proof * pr, expr_
|
|||
else {
|
||||
// replacing entry
|
||||
m_manager.inc_ref(q);
|
||||
m_manager.dec_ref(entry->get_data().m_value);
|
||||
entry->get_data().m_value = q;
|
||||
m_manager.dec_ref(entry);
|
||||
entry = q;
|
||||
if (proofs_enabled()) {
|
||||
obj_map<func_decl, proof *>::obj_map_entry * entry_pr = m_decl2macro_pr->find_core(f);
|
||||
SASSERT(entry_pr != 0);
|
||||
|
|
|
@ -24,8 +24,7 @@ void num_occurs::process(expr * t, expr_fast_mark1 & visited) {
|
|||
|
||||
#define VISIT(ARG) { \
|
||||
if (!m_ignore_ref_count1 || ARG->get_ref_count() > 1) { \
|
||||
obj_map<expr, unsigned>::obj_map_entry * entry = m_num_occurs.insert_if_not_there2(ARG, 0); \
|
||||
entry->get_data().m_value++; \
|
||||
m_num_occurs.insert_if_not_there(ARG, 0)++; \
|
||||
} \
|
||||
if (!visited.is_marked(ARG)) { \
|
||||
visited.mark(ARG, true); \
|
||||
|
|
|
@ -458,10 +458,10 @@ namespace recfun {
|
|||
for (expr* t : subterms(tmp)) {
|
||||
if (is_app(t)) {
|
||||
for (expr* arg : *to_app(t)) {
|
||||
parents.insert_if_not_there2(arg, ptr_vector<expr>())->get_data().m_value.push_back(t);
|
||||
parents.insert_if_not_there(arg, ptr_vector<expr>()).push_back(t);
|
||||
}
|
||||
}
|
||||
by_depth.insert_if_not_there2(get_depth(t), ptr_vector<expr>())->get_data().m_value.push_back(t);
|
||||
by_depth.insert_if_not_there(get_depth(t), ptr_vector<expr>()).push_back(t);
|
||||
}
|
||||
unsigned max_depth = get_depth(e);
|
||||
scores.insert(e, 0);
|
||||
|
|
|
@ -25,11 +25,11 @@ void counter::update(unsigned el, int delta) {
|
|||
}
|
||||
|
||||
int & counter::get(unsigned el) {
|
||||
return m_data.insert_if_not_there2(el, 0)->get_data().m_value;
|
||||
return m_data.insert_if_not_there(el, 0);
|
||||
}
|
||||
|
||||
counter & counter::count(unsigned sz, const unsigned * els, int delta) {
|
||||
for(unsigned i=0; i<sz; i++) {
|
||||
for(unsigned i = 0; i < sz; i++) {
|
||||
update(els[i], delta);
|
||||
}
|
||||
return *this;
|
||||
|
@ -37,32 +37,24 @@ counter & counter::count(unsigned sz, const unsigned * els, int delta) {
|
|||
|
||||
unsigned counter::get_positive_count() const {
|
||||
unsigned cnt = 0;
|
||||
iterator eit = begin();
|
||||
iterator eend = end();
|
||||
for(; eit!=eend; ++eit) {
|
||||
if( eit->m_value>0 ) {
|
||||
for (auto const& kv : *this)
|
||||
if (kv.m_value > 0)
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
void counter::collect_positive(uint_set & acc) const {
|
||||
iterator eit = begin();
|
||||
iterator eend = end();
|
||||
for(; eit!=eend; ++eit) {
|
||||
if(eit->m_value>0) { acc.insert(eit->m_key); }
|
||||
}
|
||||
for (auto const& kv : *this)
|
||||
if(kv.m_value > 0)
|
||||
acc.insert(kv.m_key);
|
||||
}
|
||||
|
||||
bool counter::get_max_positive(unsigned & res) const {
|
||||
bool found = false;
|
||||
iterator eit = begin();
|
||||
iterator eend = end();
|
||||
for(; eit!=eend; ++eit) {
|
||||
if( eit->m_value>0 && (!found || eit->m_key>res) ) {
|
||||
for (auto const& kv : *this) {
|
||||
if (kv.m_value > 0 && (!found || kv.m_key > res) ) {
|
||||
found = true;
|
||||
res = eit->m_key;
|
||||
res = kv.m_key;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
|
@ -76,12 +68,9 @@ unsigned counter::get_max_positive() const {
|
|||
|
||||
int counter::get_max_counter_value() const {
|
||||
int res = 0;
|
||||
iterator eit = begin();
|
||||
iterator eend = end();
|
||||
for (; eit!=eend; ++eit) {
|
||||
if( eit->m_value>res ) {
|
||||
res = eit->m_value;
|
||||
}
|
||||
for (auto const& kv : *this) {
|
||||
if (kv.m_value > res)
|
||||
res = kv.m_value;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class ast_counter {
|
|||
iterator end() const { return m_data.end(); }
|
||||
|
||||
int & get(ast * el) {
|
||||
return m_data.insert_if_not_there2(el, 0)->get_data().m_value;
|
||||
return m_data.insert_if_not_there(el, 0);
|
||||
}
|
||||
void update(ast * el, int delta){
|
||||
get(el) += delta;
|
||||
|
|
|
@ -523,10 +523,10 @@ bool bv_bounds::bound_lo(app * v, const numeral& l) {
|
|||
SASSERT(in_range(v, l));
|
||||
TRACE("bv_bounds", tout << "lower " << mk_ismt2_pp(v, m_m) << ":" << l << std::endl;);
|
||||
// l <= v
|
||||
bound_map::obj_map_entry * const entry = m_unsigned_lowers.insert_if_not_there2(v, l);
|
||||
if (!(entry->get_data().m_value < l)) return m_okay;
|
||||
auto& value = m_unsigned_lowers.insert_if_not_there(v, l);
|
||||
if (!(value < l)) return m_okay;
|
||||
// improve bound
|
||||
entry->get_data().m_value = l;
|
||||
value = l;
|
||||
return m_okay;
|
||||
}
|
||||
|
||||
|
@ -534,10 +534,10 @@ bool bv_bounds::bound_up(app * v, const numeral& u) {
|
|||
SASSERT(in_range(v, u));
|
||||
TRACE("bv_bounds", tout << "upper " << mk_ismt2_pp(v, m_m) << ":" << u << std::endl;);
|
||||
// v <= u
|
||||
bound_map::obj_map_entry * const entry = m_unsigned_uppers.insert_if_not_there2(v, u);
|
||||
if (!(u < entry->get_data().m_value)) return m_okay;
|
||||
auto& value = m_unsigned_uppers.insert_if_not_there(v, u);
|
||||
if (!(u < value)) return m_okay;
|
||||
// improve bound
|
||||
entry->get_data().m_value = u;
|
||||
value = u;
|
||||
return m_okay;
|
||||
}
|
||||
|
||||
|
|
|
@ -341,11 +341,8 @@ bool factor_rewriter::extract_factors() {
|
|||
|
||||
void factor_rewriter::collect_powers() {
|
||||
m_powers.reset();
|
||||
for (unsigned i = 0; i < m_factors.size(); ++i) {
|
||||
obj_map<expr,unsigned>::obj_map_entry* entry = m_powers.insert_if_not_there2(m_factors[i].get(), 0);
|
||||
if (entry) {
|
||||
++(entry->get_data().m_value);
|
||||
}
|
||||
for (expr* f : m_factors) {
|
||||
m_powers.insert_if_not_there(f, 0)++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1326,7 +1326,7 @@ seq_rewriter::length_comparison seq_rewriter::compare_lengths(unsigned sza, expr
|
|||
if (m_util.str.is_unit(as[i]))
|
||||
units_a++;
|
||||
else
|
||||
mults.insert_if_not_there2(as[i], 0)->get_data().m_value++;
|
||||
mults.insert_if_not_there(as[i], 0)++;
|
||||
}
|
||||
for (unsigned i = 0; i < szb; ++i) {
|
||||
if (m_util.str.is_unit(bs[i]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue