3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-12 11:54:07 +00:00

Remove copies (#8583)

This commit is contained in:
Nuno Lopes 2026-02-11 18:14:36 +00:00 committed by GitHub
parent 0da28c6d19
commit 836a76c78a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 38 additions and 51 deletions

View file

@ -727,7 +727,7 @@ namespace euf {
m_hopat2pat.insert(p1, p);
m_q2hoq.insert(q, q1);
m_hoq2q.insert(q1, q);
m_hopat2free_vars.insert(p1, free_vars);
m_hopat2free_vars.insert(p1, std::move(free_vars));
m_ho_patterns.push_back(p1);
m_ho_qs.push_back(q1);
trail().push(push_back_vector(m_ho_patterns));

View file

@ -123,7 +123,7 @@ namespace polymorphism {
expr_ref e_inst = new_sub(e);
if (!m_from_instantiation.contains(e_inst)) {
collect_instantiations(e_inst);
auto* new_sub1 = alloc(substitution, new_sub);
auto* new_sub1 = alloc(substitution, std::move(new_sub));
instances.push_back(instantiation(e, e_inst, new_sub1));
new_substs.insert(new_sub1);
m_from_instantiation.insert(e_inst);

View file

@ -2133,7 +2133,7 @@ namespace polynomial {
m_m2pos.reset(m);
m_m2pos.set(m, i);
}
m_tmp_as.swap(new_as);
m_tmp_as = std::move(new_as);
}
// For each monomial m

View file

@ -301,7 +301,6 @@ namespace upolynomial {
void core_manager::sub(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer) {
sub_core(sz1, p1, sz2, p2, m_basic_tmp);
// buffer = std::move(m_basic_tmp);
buffer.swap(m_basic_tmp);
}
@ -343,7 +342,6 @@ namespace upolynomial {
void core_manager::mul(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer) {
mul_core(sz1, p1, sz2, p2, m_basic_tmp);
// buffer = std::move(m_basic_tmp);
buffer.swap(m_basic_tmp);
}

View file

@ -1145,7 +1145,7 @@ namespace datalog {
set_difference(local_deltas, global_deltas);
*/
func_decl_set local_deltas;
func_decl_set global_deltas(head_preds);
const func_decl_set & global_deltas = head_preds;
pred2idx d_global_src; //these deltas serve as sources of tuples for rule evaluation inside the loop
get_fresh_registers(global_deltas, d_global_src);

View file

@ -837,8 +837,8 @@ namespace datalog {
SASSERT(&expl_singleton->get_plugin()==m_er_plugin);
m_e_fact_relation = static_cast<explanation_relation *>(expl_singleton);
}
func_decl_set predicates(m_context.get_predicates());
for (func_decl* orig_decl : predicates) {
for (func_decl* orig_decl : m_context.get_predicates()) {
TRACE(dl, tout << mk_pp(orig_decl, m_manager) << "\n";);
func_decl * e_decl = get_e_decl(orig_decl);

View file

@ -29,16 +29,14 @@ namespace nlsat {
public:
scoped_literal_vector(solver & s):m_solver(s) {}
~scoped_literal_vector() { reset(); }
scoped_literal_vector(scoped_literal_vector && other) noexcept = default;
// Move assignment operator
scoped_literal_vector & operator=(scoped_literal_vector && other) noexcept {
if (this != &other) {
SASSERT(&m_solver == &other.m_solver);
reset(); // dec_ref our current literals
m_lits = std::move(other.m_lits); // take ownership of other's literals
// other.m_lits is now empty
m_lits = std::move(other.m_lits);
}
return *this;
}

View file

@ -385,10 +385,9 @@ namespace qe {
// They are sorted by size, so we project the largest variables first to avoid
// renaming variables.
for (unsigned i = vars.size(); i-- > 0;) {
new_result.reset();
ex.project(vars[i], result.size(), result.data(), new_result);
TRACE(qe, display_project(tout, vars[i], result, new_result););
result.swap(new_result);
result = std::move(new_result);
}
negate_clause(result);
}

View file

@ -358,7 +358,7 @@ namespace arith {
continue;
m_ineqs_that_are_eqs.insert(j);
if (j < orig_size) {
m_eqs.push_back(m_ineqs[j]);
m_eqs.push_back(std::move(m_ineqs[j]));
}
else {
auto [a, b] = m_deps[j];

View file

@ -239,7 +239,7 @@ void proto_model::cleanup() {
unregister_decl(faux);
}
}
m_aux_decls.swap(found_aux_fs);
m_aux_decls = std::move(found_aux_fs);
}
TRACE(model_bug, model_v2_pp(tout, *this););
}

View file

@ -201,7 +201,7 @@ struct mus::imp {
}
if (!min_core_valid || core.size() < min_core.size()) {
// The current core is smallest so far, so we get fewer unknowns from it.
min_core = core;
min_core = std::move(core);
min_core_valid = true;
min_lit = lit;
}

View file

@ -29,13 +29,13 @@ Revision History:
*/
template<typename T>
class obj_hash_entry {
T * m_ptr = nullptr;
T * m_ptr = nullptr;
public:
typedef T * data;
unsigned get_hash() const { return m_ptr->hash(); }
bool is_free() const { return m_ptr == nullptr; }
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
bool is_used() const { return m_ptr != nullptr && m_ptr != reinterpret_cast<T *>(1); }
T * get_data() const { return m_ptr; }
T * & get_data() { return m_ptr; }
void set_data(T * d) { m_ptr = d; }
@ -50,21 +50,18 @@ public:
obj_hashtable(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY):
core_hashtable<obj_hash_entry<T>, obj_ptr_hash<T>, ptr_eq<T> >(initial_capacity) {}
obj_hashtable(const obj_hashtable & source) = default;
obj_hashtable(obj_hashtable && source) noexcept = default;
obj_hashtable& operator=(const obj_hashtable & other) = delete;
obj_hashtable& operator=(obj_hashtable && other) noexcept = default;
};
template<typename Key, typename Value>
class obj_map {
public:
struct key_data {
Key * m_key = nullptr;
Value m_value;
key_data() {}
key_data(Key *key) : m_key(key) {}
key_data(Key *k, Value const &v) : m_key(k), m_value(v) {}
key_data(key_data &&kd) noexcept = default;
key_data(key_data const &kd) noexcept = default;
key_data &operator=(key_data const &kd) = default;
key_data &operator=(key_data &&kd) = default;
Key * m_key = nullptr;
Value m_value;
Value const & get_value() const { return m_value; }
Key & get_key () const { return *m_key; }
unsigned hash() const { return m_key->hash(); }
@ -94,7 +91,12 @@ public:
public:
obj_map(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY):
m_table(initial_capacity) {}
obj_map(const obj_map & source) = default;
obj_map(obj_map && source) noexcept = default;
obj_map& operator=(const obj_map & other) = delete;
obj_map& operator=(obj_map && other) noexcept = default;
typedef typename table::iterator iterator;
typedef typename table::data data;
typedef typename table::entry entry;
@ -141,16 +143,22 @@ public:
return m_table.insert_if_not_there2(key_data(k, v))->get_data().m_value;
}
Value& insert_if_not_there(Key * k, Value && v) {
obj_map_entry * e = nullptr;
m_table.insert_if_not_there_core({k, std::move(v)}, e);
return e->get_data().m_value;
}
bool insert_if_not_there_core(Key * k, Value const & v, obj_map_entry * & et) {
return m_table.insert_if_not_there_core({k, v}, et);
}
obj_map_entry * insert_if_not_there3(Key * k, Value const & v) {
return m_table.insert_if_not_there2(key_data(k, v));
return m_table.insert_if_not_there2({k, v});
}
obj_map_entry * find_core(Key * k) const {
return m_table.find_core(key_data(k));
return m_table.find_core({k});
}
bool find(Key * const k, Value & v) const {

View file

@ -19,10 +19,6 @@ Revision History:
#include "util/s_integer.h"
s_integer s_integer::m_zero(0);
s_integer s_integer::m_one(1);
s_integer s_integer::m_minus_one(-1);
s_integer::s_integer(const char * str) {
m_val = static_cast<int>(strtol(str, nullptr, 10));
}

View file

@ -22,9 +22,6 @@ Revision History:
class s_integer {
int m_val = 0;
static s_integer m_zero;
static s_integer m_one;
static s_integer m_minus_one;
public:
unsigned hash() const {
@ -39,10 +36,6 @@ public:
public:
s_integer() = default;
explicit s_integer(int n):m_val(n) {}
struct i64 {};
explicit s_integer(int64_t i, i64):m_val(static_cast<int>(i)) {}
struct ui64 {};
explicit s_integer(uint64_t i, ui64):m_val(static_cast<int>(i)) {}
explicit s_integer(const char * str);
explicit s_integer(const rational & r):m_val(static_cast<int>(r.get_int64())) {}
@ -58,12 +51,12 @@ public:
uint64_t get_uint64() const { return m_val; }
static bool is_unsigned() { return true; }
unsigned get_unsigned() const { return static_cast<unsigned>(m_val); }
s_integer const& get_s_integer() const { return *this; }
s_integer const& get_infinitesimal() const { return zero(); }
s_integer get_s_integer() const { return *this; }
s_integer get_infinitesimal() const { return s_integer(0); }
static bool is_rational() { return true; }
s_integer const& get_rational() const { return *this; }
friend inline s_integer numerator(const s_integer & r) { return r; }
friend inline s_integer denominator(const s_integer & r) { return one(); }
friend inline s_integer denominator(const s_integer & r) { return s_integer(1); }
s_integer & operator+=(const s_integer & r) { m_val += r.m_val; return *this; }
s_integer & operator-=(const s_integer & r) { m_val -= r.m_val; return *this; }
s_integer & operator*=(const s_integer & r) { m_val *= r.m_val; return *this; }
@ -103,9 +96,6 @@ public:
return result;
}
static const s_integer & zero() { return m_zero; }
static const s_integer & one() { return m_one; }
static const s_integer & minus_one() { return m_minus_one; }
// Perform: this += c * k
void addmul(const s_integer & c, const s_integer & k) { m_val += c.m_val * k.m_val; }
void submul(const s_integer & c, const s_integer & k) { m_val -= c.m_val * k.m_val; }
@ -137,5 +127,3 @@ inline s_integer abs(const s_integer & r) {
}
return result;
}