mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 00:27:42 +00:00
Runtime: Collapse emplace_back() calls where applicable
Same behavior, but with less code.
This commit is contained in:
@@ -29,14 +29,14 @@ u8* CGameAllocator::Alloc(size_t len) {
|
||||
|
||||
/* Pad size to allow for allocation information */
|
||||
allocSz = ROUND_UP_64(allocSz + sizeof(SChunkDescription));
|
||||
m_allocations.emplace_back();
|
||||
m_allocations.back().memptr.reset(new u8[allocSz]);
|
||||
u8* ptr = m_allocations.back().memptr.get();
|
||||
m_allocations.back().allocSize = allocSz;
|
||||
m_allocations.back().freeOffset += roundedLen;
|
||||
auto& alloc = m_allocations.emplace_back();
|
||||
alloc.memptr.reset(new u8[allocSz]);
|
||||
u8* ptr = alloc.memptr.get();
|
||||
alloc.allocSize = allocSz;
|
||||
alloc.freeOffset += roundedLen;
|
||||
SChunkDescription* chunkInfo = reinterpret_cast<SChunkDescription*>(ptr);
|
||||
*chunkInfo = SChunkDescription();
|
||||
chunkInfo->parent = &m_allocations.back();
|
||||
chunkInfo->parent = &alloc;
|
||||
chunkInfo->len = len;
|
||||
return ptr + sizeof(SChunkDescription);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user