From cf8d2e67e36042c808c2773f38a5a023bda4a746 Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Mon, 12 Nov 2018 10:19:45 +0800 Subject: [PATCH] clean buffered_allocator --- paddle/fluid/memory/allocation/buffered_allocator.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/memory/allocation/buffered_allocator.cc b/paddle/fluid/memory/allocation/buffered_allocator.cc index ca6776504..18d02f6f6 100644 --- a/paddle/fluid/memory/allocation/buffered_allocator.cc +++ b/paddle/fluid/memory/allocation/buffered_allocator.cc @@ -36,20 +36,16 @@ BufferedAllocator::~BufferedAllocator() { FreeCache(-1UL); } std::unique_ptr BufferedAllocator::Allocate(size_t size, Allocator::Attr attr) { - std::unique_ptr result; { platform::LockGuardPtr guard(mtx_); auto it = allocations_.lower_bound(size); if (it != allocations_.end() && it->first < size * 2) { - result = std::move(it->second); + std::unique_ptr result(std::move(it->second)); allocations_.erase(it); + return result; } } - if (result) { - return result; - } - try { return underlying_allocator_->Allocate(size, attr); } catch (BadAlloc&) { -- GitLab