| 41 | } |
| 42 | |
| 43 | void RefCountableAutoreleasePool::append(void* ptr) { |
| 44 | // If our append will cause a reallocation, but we have some free spots available |
| 45 | // at the beginning, shift the array and reset the index to avoid the allocation. |
| 46 | if (_entriesIndex > 0 && _entries.size() + 1 >= _entries.capacity()) { |
| 47 | _entries.erase(_entries.begin(), _entries.begin() + _entriesIndex); |
| 48 | _entriesIndex = 0; |
| 49 | } |
| 50 | |
| 51 | _entries.emplace_back(ptr); |
| 52 | } |
| 53 | |
| 54 | size_t RefCountableAutoreleasePool::backingArraySize() const { |
| 55 | return _entries.size(); |