Skip to content

Commit cf8d2e6

Browse files
committed
clean buffered_allocator
1 parent 6ae0b91 commit cf8d2e6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

paddle/fluid/memory/allocation/buffered_allocator.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,16 @@ BufferedAllocator::~BufferedAllocator() { FreeCache(-1UL); }
3636

3737
std::unique_ptr<Allocation> BufferedAllocator::Allocate(size_t size,
3838
Allocator::Attr attr) {
39-
std::unique_ptr<Allocation> result;
4039
{
4140
platform::LockGuardPtr<std::mutex> guard(mtx_);
4241
auto it = allocations_.lower_bound(size);
4342
if (it != allocations_.end() && it->first < size * 2) {
44-
result = std::move(it->second);
43+
std::unique_ptr<Allocation> result(std::move(it->second));
4544
allocations_.erase(it);
45+
return result;
4646
}
4747
}
4848

49-
if (result) {
50-
return result;
51-
}
52-
5349
try {
5450
return underlying_allocator_->Allocate(size, attr);
5551
} catch (BadAlloc&) {

0 commit comments

Comments
 (0)