mirror of
https://github.com/Z3Prover/z3
synced 2026-07-02 21:36:09 +00:00
replace some copies with moves
This commit is contained in:
parent
6b28d65487
commit
a3e7bbb92f
8 changed files with 27 additions and 13 deletions
|
|
@ -324,20 +324,20 @@ struct pb2bv_rewriter::imp {
|
||||||
unsigned c = m_coeffs[i].get_unsigned();
|
unsigned c = m_coeffs[i].get_unsigned();
|
||||||
v.push_back(c >= k ? k : c);
|
v.push_back(c >= k ? k : c);
|
||||||
e.push_back(args[i]);
|
e.push_back(args[i]);
|
||||||
es.push_back(e);
|
es.push_back(std::move(e));
|
||||||
coeffs.push_back(v);
|
coeffs.push_back(std::move(v));
|
||||||
}
|
}
|
||||||
while (es.size() > 1) {
|
while (es.size() > 1) {
|
||||||
for (unsigned i = 0; i + 1 < es.size(); i += 2) {
|
for (unsigned i = 0; i + 1 < es.size(); i += 2) {
|
||||||
expr_ref_vector o(m);
|
expr_ref_vector o(m);
|
||||||
unsigned_vector oc;
|
unsigned_vector oc;
|
||||||
tot_adder(es[i], coeffs[i], es[i + 1], coeffs[i + 1], k, o, oc);
|
tot_adder(es[i], coeffs[i], es[i + 1], coeffs[i + 1], k, o, oc);
|
||||||
es[i / 2].set(o);
|
es[i / 2] = std::move(o);
|
||||||
coeffs[i / 2] = oc;
|
coeffs[i / 2] = std::move(oc);
|
||||||
}
|
}
|
||||||
if ((es.size() % 2) == 1) {
|
if ((es.size() % 2) == 1) {
|
||||||
es[es.size() / 2].set(es.back());
|
es[es.size() / 2] = std::move(es.back());
|
||||||
coeffs[es.size() / 2] = coeffs.back();
|
coeffs[es.size() / 2] = std::move(coeffs.back());
|
||||||
}
|
}
|
||||||
es.shrink((1 + es.size())/2);
|
es.shrink((1 + es.size())/2);
|
||||||
coeffs.shrink((1 + coeffs.size())/2);
|
coeffs.shrink((1 + coeffs.size())/2);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@ class expr_offset {
|
||||||
public:
|
public:
|
||||||
expr_offset() = default;
|
expr_offset() = default;
|
||||||
expr_offset(expr * e, unsigned o):m_expr(e), m_offset(o) {}
|
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; }
|
expr * get_expr() const { return m_expr; }
|
||||||
unsigned get_offset() const { return m_offset; }
|
unsigned get_offset() const { return m_offset; }
|
||||||
|
|
|
||||||
|
|
@ -2129,8 +2129,7 @@ namespace polynomial {
|
||||||
for (unsigned i = 0; i < sz; ++i) {
|
for (unsigned i = 0; i < sz; ++i) {
|
||||||
monomial * m = m_tmp_ms[i];
|
monomial * m = m_tmp_ms[i];
|
||||||
unsigned pos = m_m2pos.get(m);
|
unsigned pos = m_m2pos.get(m);
|
||||||
new_as.push_back(numeral());
|
new_as.push_back(std::move(m_tmp_as[pos]));
|
||||||
swap(new_as.back(), m_tmp_as[pos]);
|
|
||||||
m_m2pos.reset(m);
|
m_m2pos.reset(m);
|
||||||
m_m2pos.set(m, i);
|
m_m2pos.set(m, i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1953,8 +1953,8 @@ namespace nlarith {
|
||||||
for (; i + 1 < mat.size(); i += 2) {
|
for (; i + 1 < mat.size(); i += 2) {
|
||||||
if (mat[i+1].contains(Zero)) {
|
if (mat[i+1].contains(Zero)) {
|
||||||
if (i != j) {
|
if (i != j) {
|
||||||
mat[j] = mat[i];
|
mat[j] = std::move(mat[i]);
|
||||||
mat[j+1] = mat[i+1];
|
mat[j+1] = std::move(mat[i+1]);
|
||||||
}
|
}
|
||||||
j += 2;
|
j += 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,6 @@ namespace qe {
|
||||||
// They are sorted by size, so we project the largest variables first to avoid
|
// They are sorted by size, so we project the largest variables first to avoid
|
||||||
// renaming variables.
|
// renaming variables.
|
||||||
for (unsigned i = vars.size(); i-- > 0;) {
|
for (unsigned i = vars.size(); i-- > 0;) {
|
||||||
new_result.reset();
|
|
||||||
ex.project(vars[i], result.size(), result.data(), new_result);
|
ex.project(vars[i], result.size(), result.data(), new_result);
|
||||||
TRACE(qe, display_project(tout, vars[i], result, new_result););
|
TRACE(qe, display_project(tout, vars[i], result, new_result););
|
||||||
result = std::move(new_result);
|
result = std::move(new_result);
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ namespace sat {
|
||||||
lits2.insert(*it);
|
lits2.insert(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lits1 = lits3;
|
lits1 = std::move(lits3);
|
||||||
}
|
}
|
||||||
|
|
||||||
literal_vector& mus::get_core() {
|
literal_vector& mus::get_core() {
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ namespace sat {
|
||||||
}
|
}
|
||||||
bv.push_back(parity);
|
bv.push_back(parity);
|
||||||
}
|
}
|
||||||
m_parity.push_back(bv);
|
m_parity.push_back(std::move(bv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -650,6 +650,17 @@ public:
|
||||||
svector(SZ s):vector<T, false, SZ>(s) {}
|
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 & elem):vector<T, false, SZ>(s, elem) {}
|
||||||
svector(SZ s, T const * data):vector<T, false, SZ>(s, data) {}
|
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;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue