Skip to content
Draft
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
8 changes: 8 additions & 0 deletions util/mmap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class scoped_memory {
: data_(from.data_), size_(from.size_), source_(from.source_) {
from.steal();
}

scoped_memory &operator=(scoped_memory &&from) noexcept {
reset();
size_ = from.size_;
source_ = from.source_;
data_ = from.steal();
return *this;
}
#endif

~scoped_memory() { reset(); }
Expand Down
9 changes: 9 additions & 0 deletions util/probing_hash_table.hh
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,19 @@ template <class EntryT, class HashT, class EqualT = std::equal_to<typename Entry
return backend_.RawEnd();
}

void Reserve(size_t capacity) {
while (threshold_ < capacity)
Double();
}

private:
void DoubleIfNeeded() {
if (UTIL_LIKELY(Size() < threshold_))
return;
Double();
}

void Double() {
HugeRealloc(backend_.DoubleTo(), KeyIsRawZero(backend_.invalid_), mem_);
allocated_ = backend_.DoubleTo();
backend_.Double(mem_.get(), !KeyIsRawZero(backend_.invalid_));
Expand Down