2
0
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:
Lioncash
2020-03-13 16:32:24 -04:00
parent df4487bae8
commit 097d4a4422
18 changed files with 103 additions and 123 deletions

View File

@@ -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);
}