Optimize size() and empty() for WaitFreeVector.
This commit is contained in:
parent
bb5d8c0c8d
commit
2be8c86855
@ -53,15 +53,14 @@ class WaitFreeVector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t size() const {
|
size_t size() const {
|
||||||
size_t result = 0;
|
if (storage_.empty()) {
|
||||||
for (auto &storage : storage_) {
|
return 0;
|
||||||
result += storage.size();
|
|
||||||
}
|
}
|
||||||
return result;
|
return (storage_.size() - 1) * MAX_VECTOR_SIZE + storage_.back().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
return storage_.empty() || storage_[0].empty();
|
return storage_.empty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user