File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
paddle/fluid/memory/allocation Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -36,20 +36,16 @@ BufferedAllocator::~BufferedAllocator() { FreeCache(-1UL); }
36
36
37
37
std::unique_ptr<Allocation> BufferedAllocator::Allocate (size_t size,
38
38
Allocator::Attr attr) {
39
- std::unique_ptr<Allocation> result;
40
39
{
41
40
platform::LockGuardPtr<std::mutex> guard (mtx_);
42
41
auto it = allocations_.lower_bound (size);
43
42
if (it != allocations_.end () && it->first < size * 2 ) {
44
- result = std::move (it->second );
43
+ std::unique_ptr<Allocation> result ( std::move (it->second ) );
45
44
allocations_.erase (it);
45
+ return result;
46
46
}
47
47
}
48
48
49
- if (result) {
50
- return result;
51
- }
52
-
53
49
try {
54
50
return underlying_allocator_->Allocate (size, attr);
55
51
} catch (BadAlloc&) {
You can’t perform that action at this time.
0 commit comments