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

replace some copies with moves

This commit is contained in:
Nuno Lopes 2026-02-09 22:45:13 +00:00
parent 73844f9a7f
commit 617c621cc0
8 changed files with 27 additions and 13 deletions

View file

@ -324,20 +324,20 @@ struct pb2bv_rewriter::imp {
unsigned c = m_coeffs[i].get_unsigned();
v.push_back(c >= k ? k : c);
e.push_back(args[i]);
es.push_back(e);
coeffs.push_back(v);
es.push_back(std::move(e));
coeffs.push_back(std::move(v));
}
while (es.size() > 1) {
for (unsigned i = 0; i + 1 < es.size(); i += 2) {
expr_ref_vector o(m);
unsigned_vector oc;
tot_adder(es[i], coeffs[i], es[i + 1], coeffs[i + 1], k, o, oc);
es[i / 2].set(o);
coeffs[i / 2] = oc;
es[i / 2] = std::move(o);
coeffs[i / 2] = std::move(oc);
}
if ((es.size() % 2) == 1) {
es[es.size() / 2].set(es.back());
coeffs[es.size() / 2] = coeffs.back();
es[es.size() / 2] = std::move(es.back());
coeffs[es.size() / 2] = std::move(coeffs.back());
}
es.shrink((1 + es.size())/2);
coeffs.shrink((1 + coeffs.size())/2);

View file

@ -31,6 +31,11 @@ class expr_offset {
public:
expr_offset() = default;
expr_offset(expr * e, unsigned o):m_expr(e), m_offset(o) {}
expr_offset(const expr_offset&) = default;
expr_offset(expr_offset&&) noexcept = default;
expr_offset& operator=(expr_offset const & other) = default;
expr_offset& operator=(expr_offset&&) noexcept = default;
expr * get_expr() const { return m_expr; }
unsigned get_offset() const { return m_offset; }

View file

@ -2129,8 +2129,7 @@ namespace polynomial {
for (unsigned i = 0; i < sz; ++i) {
monomial * m = m_tmp_ms[i];
unsigned pos = m_m2pos.get(m);
new_as.push_back(numeral());
swap(new_as.back(), m_tmp_as[pos]);
new_as.push_back(std::move(m_tmp_as[pos]));
m_m2pos.reset(m);
m_m2pos.set(m, i);
}

View file

@ -1953,8 +1953,8 @@ namespace nlarith {
for (; i + 1 < mat.size(); i += 2) {
if (mat[i+1].contains(Zero)) {
if (i != j) {
mat[j] = mat[i];
mat[j+1] = mat[i+1];
mat[j] = std::move(mat[i]);
mat[j+1] = std::move(mat[i+1]);
}
j += 2;
}

View file

@ -385,7 +385,6 @@ 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 = std::move(new_result);

View file

@ -208,7 +208,7 @@ namespace sat {
lits2.insert(*it);
}
}
lits1 = lits3;
lits1 = std::move(lits3);
}
literal_vector& mus::get_core() {

View file

@ -210,7 +210,7 @@ namespace sat {
}
bv.push_back(parity);
}
m_parity.push_back(bv);
m_parity.push_back(std::move(bv));
}
}

View file

@ -650,6 +650,17 @@ public:
svector(SZ s):vector<T, false, SZ>(s) {}
svector(SZ s, T const & elem):vector<T, false, SZ>(s, elem) {}
svector(SZ s, T const * data):vector<T, false, SZ>(s, data) {}
svector(const svector&) = default;
svector(svector&&) noexcept = default;
svector & operator=(const svector & source) {
vector<T, false, SZ>::operator=(source);
return *this;
}
svector & operator=(svector && source) noexcept {
vector<T, false, SZ>::operator=(std::move(source));
return *this;
}
};