2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 11:07:44 +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

@@ -30,8 +30,7 @@ void CMapArea::PostConstruct() {
m_mappableObjects.reserve(x28_mappableObjCount);
for (u32 i = 0, j = 0; i < x28_mappableObjCount; ++i, j += 0x50) {
m_mappableObjects.emplace_back(x38_moStart + j);
m_mappableObjects.back().PostConstruct(x44_buf.get());
m_mappableObjects.emplace_back(x38_moStart + j).PostConstruct(x44_buf.get());
}
u8* tmp = x3c_vertexStart;
@@ -45,8 +44,7 @@ void CMapArea::PostConstruct() {
std::vector<u32> index;
m_surfaces.reserve(x30_surfaceCount);
for (u32 i = 0, j = 0; i < x30_surfaceCount; ++i, j += 32) {
m_surfaces.emplace_back(x40_surfaceStart + j);
m_surfaces.back().PostConstruct(x44_buf.get(), index);
m_surfaces.emplace_back(x40_surfaceStart + j).PostConstruct(x44_buf.get(), index);
}
CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx) {
@@ -60,8 +58,7 @@ void CMapArea::PostConstruct() {
CMapAreaSurface& surf = m_surfaces[i];
surf.m_instances.reserve(instCount);
for (u32 inst = 0; inst < instCount; ++inst) {
surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
CMapAreaSurface::Instance& instance = surf.m_instances.back();
CMapAreaSurface::Instance& instance = surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
u32 outlineCount = r.readUint32Big();