Skip to content

Commit

Permalink
Simplify move constructors. (#5409)
Browse files Browse the repository at this point in the history
Partially reverts #5412.

---
TYPE: NO_HISTORY
  • Loading branch information
teo-tsirpanis authored Jan 7, 2025
1 parent 9013c66 commit 468046c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
6 changes: 1 addition & 5 deletions tiledb/sm/filter/filter_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ FilterBuffer::BufferOrView::BufferOrView(
tdb_new(Buffer, (char*)buffer->data() + offset, nbytes));
}

FilterBuffer::BufferOrView::BufferOrView(BufferOrView&& other) {
underlying_buffer_.swap(other.underlying_buffer_);
view_.swap(other.view_);
std::swap(is_view_, other.is_view_);
}
FilterBuffer::BufferOrView::BufferOrView(BufferOrView&& other) = default;

Buffer* FilterBuffer::BufferOrView::buffer() const {
return is_view_ ? view_.get() : underlying_buffer_.get();
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/filter/filter_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class FilterBuffer {
shared_ptr<Buffer> underlying_buffer_;

/** True if this instance is a view on the underlying buffer. */
bool is_view_{false};
bool is_view_;

/**
* If this instance is a view, the view Buffer (which does not own its
Expand Down
11 changes: 4 additions & 7 deletions tiledb/sm/filter/filter_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ FilterPipeline::FilterPipeline(
, max_chunk_size_(max_chunk_size) {
}

// Unlike move constructors, copy constructors must not use default,
// because individual filters are being copied by calling clone.
FilterPipeline::FilterPipeline(const FilterPipeline& other) {
for (auto& filter : other.filters_) {
add_filter(*filter);
Expand All @@ -85,9 +87,7 @@ FilterPipeline::FilterPipeline(
max_chunk_size_ = other.max_chunk_size_;
}

FilterPipeline::FilterPipeline(FilterPipeline&& other) {
swap(other);
}
FilterPipeline::FilterPipeline(FilterPipeline&& other) = default;

FilterPipeline& FilterPipeline::operator=(const FilterPipeline& other) {
// Call copy constructor
Expand All @@ -97,10 +97,7 @@ FilterPipeline& FilterPipeline::operator=(const FilterPipeline& other) {
return *this;
}

FilterPipeline& FilterPipeline::operator=(FilterPipeline&& other) {
swap(other);
return *this;
}
FilterPipeline& FilterPipeline::operator=(FilterPipeline&& other) = default;

void FilterPipeline::add_filter(const Filter& filter) {
shared_ptr<Filter> copy(filter.clone());
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/filter/filter_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class FilterPipeline {
std::vector<shared_ptr<Filter>> filters_;

/** The max chunk size allowed within tiles. */
uint32_t max_chunk_size_{0};
uint32_t max_chunk_size_;

/**
* Get the chunk offsets for a var sized tile so that integral cells are
Expand Down

0 comments on commit 468046c

Please sign in to comment.