Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/ComputeCxx/Comparison/Compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Compare::Enum::~Enum() {
}
}

Compare::Frame::Frame(vector<Enum, 8, uint64_t> *enums): _enums(enums), _start(enums->size()) {

}

Compare::Frame::~Frame() {
while (_enums->size() > _start) {
_enums->pop_back();
Expand All @@ -57,6 +61,8 @@ Compare::Frame::~Frame() {

bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t offset,
size_t size, AGComparisonOptions options) {
Frame frame = Frame(&_enums);

size_t end = size < 0 ? ~0 : offset + size;

ValueLayoutReader reader = ValueLayoutReader(layout);
Expand Down
1 change: 1 addition & 0 deletions Sources/ComputeCxx/Comparison/Compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Compare {
uint64_t _start;

public:
Frame(vector<Enum, 8, uint64_t> *enums);
~Frame();
};

Expand Down
48 changes: 46 additions & 2 deletions Sources/ComputeCxx/Vector/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class vector {

// Move

vector(vector &&);
vector &operator=(vector &&);
vector(vector &&) noexcept;
vector &operator=(vector &&) noexcept;

// Element access

Expand Down Expand Up @@ -162,6 +162,50 @@ vector<T, _inline_capacity, size_type>::~vector() {
}
}

template <typename T, unsigned int _inline_capacity, typename size_type>
requires std::unsigned_integral<size_type>
vector<T, _inline_capacity, size_type>::vector(vector &&other) noexcept
: _size(std::exchange(other._size, 0)), _capacity(std::exchange(other._capacity, _inline_capacity)) {
if (other._buffer) {
_buffer = std::exchange(other._buffer, nullptr);
} else {
for (auto i = 0; i < _size; ++i) {
new (&_inline_buffer[i]) T(std::move(other._inline_buffer[i]));
other._inline_buffer[i].~T();
}
_buffer = nullptr;
}
}

template <typename T, unsigned int _inline_capacity, typename size_type>
requires std::unsigned_integral<size_type>
vector<T, _inline_capacity, size_type> &vector<T, _inline_capacity, size_type>::operator=(vector &&other) noexcept {
if (this != &other) {
for (auto i = 0; i < _size; i++) {
data()[i].~T();
}
if (_buffer) {
free(_buffer);
}
if (other._buffer) {
_buffer = std::exchange(other._buffer, nullptr);
_size = other._size;
_capacity = other._capacity;
} else {
for (auto i = 0; i < other._size; ++i) {
new (&_inline_buffer[i]) T(std::move(other._inline_buffer[i]));
other._inline_buffer[i].~T();
}
_buffer = nullptr;
_size = other._size;
_capacity = other._capacity;
}
other._size = 0;
other._capacity = _inline_capacity;
}
return *this;
}

template <typename T, unsigned int _inline_capacity, typename size_type>
requires std::unsigned_integral<size_type>
void vector<T, _inline_capacity, size_type>::reserve_slow(size_type new_cap) {
Expand Down
Loading