[Improvement][chore] add const to all operator== (#11251)
This commit is contained in:
@ -506,12 +506,12 @@ public:
|
||||
// Used like if (res == Status::OK())
|
||||
// if the state is ok, then both code and precise code is not initialized properly, so that should check ok state
|
||||
// ignore error messages during comparison
|
||||
bool operator==(const Status& st) {
|
||||
bool operator==(const Status& st) const {
|
||||
return ok() ? st.ok() : code() == st.code() && precise_code() == st.precise_code();
|
||||
}
|
||||
|
||||
// Used like if (res != Status::OK())
|
||||
bool operator!=(const Status& st) {
|
||||
bool operator!=(const Status& st) const {
|
||||
return ok() ? !st.ok() : code() != st.code() || precise_code() != st.precise_code();
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ public:
|
||||
int64_t size() const { return _num_nodes; }
|
||||
|
||||
// Returns the number of buckets
|
||||
int64_t num_buckets() { return _buckets.size(); }
|
||||
int64_t num_buckets() const { return _buckets.size(); }
|
||||
|
||||
// Returns the number of filled buckets
|
||||
int64_t num_filled_buckets() const { return _num_filled_buckets; }
|
||||
@ -286,11 +286,11 @@ public:
|
||||
return _node->matched;
|
||||
}
|
||||
|
||||
bool operator==(const Iterator& rhs) {
|
||||
bool operator==(const Iterator& rhs) const {
|
||||
return _bucket_idx == rhs._bucket_idx && _node == rhs._node;
|
||||
}
|
||||
|
||||
bool operator!=(const Iterator& rhs) {
|
||||
bool operator!=(const Iterator& rhs) const {
|
||||
return _bucket_idx != rhs._bucket_idx || _node != rhs._node;
|
||||
}
|
||||
|
||||
|
||||
@ -433,9 +433,9 @@ private:
|
||||
template <class STLContainer>
|
||||
class TemplatedElementDeleter : public BaseDeleter {
|
||||
public:
|
||||
explicit TemplatedElementDeleter<STLContainer>(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
explicit TemplatedElementDeleter(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
|
||||
virtual ~TemplatedElementDeleter<STLContainer>() { STLDeleteElements(container_ptr_); }
|
||||
virtual ~TemplatedElementDeleter() { STLDeleteElements(container_ptr_); }
|
||||
|
||||
private:
|
||||
STLContainer* container_ptr_;
|
||||
@ -466,9 +466,9 @@ private:
|
||||
template <class STLContainer>
|
||||
class TemplatedValueDeleter : public BaseDeleter {
|
||||
public:
|
||||
explicit TemplatedValueDeleter<STLContainer>(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
explicit TemplatedValueDeleter(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
|
||||
virtual ~TemplatedValueDeleter<STLContainer>() { STLDeleteValues(container_ptr_); }
|
||||
virtual ~TemplatedValueDeleter() { STLDeleteValues(container_ptr_); }
|
||||
|
||||
private:
|
||||
STLContainer* container_ptr_;
|
||||
@ -502,8 +502,8 @@ private:
|
||||
template <class STLContainer>
|
||||
class STLElementDeleter {
|
||||
public:
|
||||
STLElementDeleter<STLContainer>(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
~STLElementDeleter<STLContainer>() { STLDeleteElements(container_ptr_); }
|
||||
STLElementDeleter(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
~STLElementDeleter() { STLDeleteElements(container_ptr_); }
|
||||
|
||||
private:
|
||||
STLContainer* container_ptr_;
|
||||
@ -512,8 +512,8 @@ private:
|
||||
template <class STLContainer>
|
||||
class STLValueDeleter {
|
||||
public:
|
||||
STLValueDeleter<STLContainer>(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
~STLValueDeleter<STLContainer>() { STLDeleteValues(container_ptr_); }
|
||||
STLValueDeleter(STLContainer* ptr) : container_ptr_(ptr) {}
|
||||
~STLValueDeleter() { STLDeleteValues(container_ptr_); }
|
||||
|
||||
private:
|
||||
STLContainer* container_ptr_;
|
||||
@ -763,49 +763,6 @@ BinaryComposeBinary<F, G1, G2> BinaryCompose2(F f, G1 g1, G2 g2) {
|
||||
return BinaryComposeBinary<F, G1, G2>(f, g1, g2);
|
||||
}
|
||||
|
||||
// This is a wrapper for an STL allocator which keeps a count of the
|
||||
// active bytes allocated by this class of allocators. This is NOT
|
||||
// THREAD SAFE. This should only be used in situations where you can
|
||||
// ensure that only a single thread performs allocation and
|
||||
// deallocation.
|
||||
template <typename T, typename Alloc = std::allocator<T>>
|
||||
class STLCountingAllocator : public Alloc {
|
||||
public:
|
||||
typedef typename Alloc::pointer pointer;
|
||||
typedef typename Alloc::size_type size_type;
|
||||
|
||||
STLCountingAllocator() : bytes_used_(NULL) {}
|
||||
STLCountingAllocator(int64* b) : bytes_used_(b) {} // TODO(user): explicit?
|
||||
|
||||
// Constructor used for rebinding
|
||||
template <class U>
|
||||
STLCountingAllocator(const STLCountingAllocator<U>& x)
|
||||
: Alloc(x), bytes_used_(x.bytes_used()) {}
|
||||
|
||||
pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0) {
|
||||
assert(bytes_used_ != NULL);
|
||||
*bytes_used_ += n * sizeof(T);
|
||||
return Alloc::allocate(n, hint);
|
||||
}
|
||||
|
||||
void deallocate(pointer p, size_type n) {
|
||||
Alloc::deallocate(p, n);
|
||||
assert(bytes_used_ != NULL);
|
||||
*bytes_used_ -= n * sizeof(T);
|
||||
}
|
||||
|
||||
// Rebind allows an allocator<T> to be used for a different type
|
||||
template <class U>
|
||||
struct rebind {
|
||||
typedef STLCountingAllocator<U, typename Alloc::template rebind<U>::other> other;
|
||||
};
|
||||
|
||||
int64* bytes_used() const { return bytes_used_; }
|
||||
|
||||
private:
|
||||
int64* bytes_used_;
|
||||
};
|
||||
|
||||
// Even though a struct has no data members, it cannot have zero size
|
||||
// according to the standard. However, "empty base-class
|
||||
// optimization" allows an empty parent class to add no additional
|
||||
|
||||
@ -362,6 +362,7 @@ void ExecEnv::_destroy() {
|
||||
SAFE_DELETE(_query_pool_mem_tracker);
|
||||
SAFE_DELETE(_load_pool_mem_tracker);
|
||||
SAFE_DELETE(_task_pool_mem_tracker_registry);
|
||||
SAFE_DELETE(_buffer_reservation);
|
||||
|
||||
DEREGISTER_HOOK_METRIC(query_mem_consumption);
|
||||
DEREGISTER_HOOK_METRIC(load_mem_consumption);
|
||||
|
||||
@ -1032,13 +1032,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const Roaring64MapSetBitForwardIterator& o) {
|
||||
bool operator==(const Roaring64MapSetBitForwardIterator& o) const {
|
||||
if (map_iter == map_end && o.map_iter == o.map_end) return true;
|
||||
if (o.map_iter == o.map_end) return false;
|
||||
return **this == *o;
|
||||
}
|
||||
|
||||
bool operator!=(const Roaring64MapSetBitForwardIterator& o) {
|
||||
bool operator!=(const Roaring64MapSetBitForwardIterator& o) const {
|
||||
if (map_iter == map_end && o.map_iter == o.map_end) return false;
|
||||
if (o.map_iter == o.map_end) return true;
|
||||
return **this != *o;
|
||||
|
||||
@ -85,9 +85,8 @@ void mt_updater(int32_t loop, T* counter, std::atomic<uint64_t>* used_time) {
|
||||
TEST_F(MetricsTest, CounterPerf) {
|
||||
static const int kLoopCount = LOOP_LESS_OR_MORE(10, 100000000);
|
||||
static const int kThreadLoopCount = LOOP_LESS_OR_MORE(1000, 1000000);
|
||||
// volatile int64_t
|
||||
{
|
||||
volatile int64_t sum = 0;
|
||||
int64_t sum = 0;
|
||||
MonotonicStopWatch watch;
|
||||
watch.start();
|
||||
for (int i = 0; i < kLoopCount; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user