提交 cf8d2e67 编写于 作者: S sneaxiy

clean buffered_allocator

上级 6ae0b91b
......@@ -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&) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册