clean buffered_allocator

panyx0718-patch-1
sneaxiy 6 years ago
parent 6ae0b91b39
commit cf8d2e67e3

@ -36,20 +36,16 @@ BufferedAllocator::~BufferedAllocator() { FreeCache(-1UL); }
std::unique_ptr<Allocation> BufferedAllocator::Allocate(size_t size,
Allocator::Attr attr) {
std::unique_ptr<Allocation> result;
{
platform::LockGuardPtr<std::mutex> guard(mtx_);
auto it = allocations_.lower_bound(size);
if (it != allocations_.end() && it->first < size * 2) {
result = std::move(it->second);
std::unique_ptr<Allocation> result(std::move(it->second));
allocations_.erase(it);
return result;
}
}
if (result) {
return result;
}
try {
return underlying_allocator_->Allocate(size, attr);
} catch (BadAlloc&) {

Loading…
Cancel
Save