3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 03:45:51 +00:00

buffer: require a move constructor to avoid copies

remove unneded copy constructors from several classes
This commit is contained in:
Nuno Lopes 2020-06-03 11:57:49 +01:00
parent 3d98bccc33
commit 98b5abb1d4
16 changed files with 38 additions and 50 deletions

View file

@ -21,7 +21,7 @@ Revision History:
--*/
#pragma once
#include<string.h>
#include <type_traits>
#include "util/memory_manager.h"
template<typename T, bool CallDestructors=true, unsigned INITIAL_SIZE=16>
@ -39,6 +39,7 @@ protected:
}
void expand() {
static_assert(std::is_nothrow_move_constructible<T>::value);
unsigned new_capacity = m_capacity << 1;
T * new_buffer = reinterpret_cast<T*>(memory::allocate(sizeof(T) * new_capacity));
for (unsigned i = 0; i < m_pos; ++i) {

View file

@ -21,8 +21,7 @@ Revision History:
--*/
#ifndef CHECKED_INT64_H_
#define CHECKED_INT64_H_
#pragma once
#include "util/z3_exception.h"
#include "util/rational.h"
@ -38,7 +37,6 @@ public:
checked_int64(): m_value(0) {}
checked_int64(int64_t v): m_value(v) {}
checked_int64(checked_int64 const& other) { m_value = other.m_value; }
class overflow_exception : public z3_exception {
char const * msg() const override { return "checked_int64 overflow/underflow";}
@ -217,5 +215,3 @@ inline checked_int64<CHECK> operator*(checked_int64<CHECK> const& a, checked_int
result *= b;
return result;
}
#endif

View file

@ -16,10 +16,10 @@ Author:
Revision History:
--*/
#ifndef HWF_H_
#define HWF_H_
#pragma once
#include<string>
#include <cstring>
#include <string>
#include "util/mpz.h"
#include "util/mpq.h"
#include "util/mpf.h"
@ -172,5 +172,3 @@ protected:
typedef _scoped_numeral<hwf_manager> scoped_hwf;
typedef _scoped_numeral_vector<hwf_manager> scoped_hwf_vector;
#endif

View file

@ -16,6 +16,7 @@ Author:
Revision History:
--*/
#include <cstring>
#include<sstream>
#include<iomanip>
#include "util/mpf.h"

View file

@ -16,6 +16,7 @@ Author:
Revision History:
--*/
#include <cstring>
#include<sstream>
#include<iomanip>
#include "util/mpfx.h"

View file

@ -16,6 +16,7 @@ Author:
Revision History:
--*/
#include <cstring>
#include <sstream>
#include <iomanip>
#include "util/mpz.h"

View file

@ -16,8 +16,7 @@ Author:
Revision History:
--*/
#ifndef MPZ_H_
#define MPZ_H_
#pragma once
#include<string>
#include "util/mutex.h"
@ -104,7 +103,7 @@ public:
mpz(int v):m_val(v), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {}
mpz():m_val(0), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {}
mpz(mpz_type* ptr): m_val(0), m_kind(mpz_small), m_owner(mpz_ext), m_ptr(ptr) { SASSERT(ptr);}
mpz(mpz && other) : m_val(other.m_val), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {
mpz(mpz && other) noexcept : m_val(other.m_val), m_kind(mpz_small), m_owner(mpz_self), m_ptr(nullptr) {
std::swap(m_ptr, other.m_ptr);
unsigned o = m_owner; m_owner = other.m_owner; other.m_owner = o;
unsigned k = m_kind; m_kind = other.m_kind; other.m_kind = k;
@ -734,6 +733,3 @@ typedef mpz_manager<false> unsynch_mpz_manager;
typedef _scoped_numeral<unsynch_mpz_manager> scoped_mpz;
typedef _scoped_numeral<synch_mpz_manager> scoped_synch_mpz;
typedef _scoped_numeral_vector<unsynch_mpz_manager> scoped_mpz_vector;
#endif /* MPZ_H_ */

View file

@ -16,8 +16,7 @@ Author:
Revision History:
--*/
#ifndef RATIONAL_H_
#define RATIONAL_H_
#pragma once
#include "util/mpq.h"
@ -41,7 +40,7 @@ public:
rational() {}
rational(rational const & r) { m().set(m_val, r.m_val); }
rational(rational && r) : m_val(std::move(r.m_val)) {}
rational(rational && r) noexcept : m_val(std::move(r.m_val)) {}
explicit rational(int n) { m().set(m_val, n); }
@ -576,7 +575,3 @@ inline rational gcd(rational const & r1, rational const & r2, rational & a, rati
rational::m().gcd(r1.m_val, r2.m_val, a.m_val, b.m_val, result.m_val);
return result;
}
#endif /* RATIONAL_H_ */