2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 13:47:43 +00:00

Runtime: Make use of std::make_unique where applicable

Makes use of the C++14 make_unique allocation function to allocate class
instances where applicable instead of a reset with a new operator within
it.

This doesn't touch cases where buffers are allocated, given make_unique
would zero-initialize them.
This commit is contained in:
Lioncash
2019-09-11 23:50:38 -04:00
parent d6166ad666
commit f9079f0215
42 changed files with 227 additions and 205 deletions

View File

@@ -149,13 +149,13 @@ bool CCollisionPrimitive::CollideMoving(const CInternalCollisionStructure::CPrim
}
void CCollisionPrimitive::InitBeginTypes() {
sCollisionTypeList.reset(new std::vector<CCollisionPrimitive::Type>());
sCollisionTypeList = std::make_unique<std::vector<Type>>();
sCollisionTypeList->reserve(3);
sTypesAdding = true;
InternalColliders::AddTypes();
}
void CCollisionPrimitive::InitAddType(const CCollisionPrimitive::Type& tp) {
void CCollisionPrimitive::InitAddType(const Type& tp) {
tp.GetSetter()(sCollisionTypeList->size());
sCollisionTypeList->push_back(tp);
}
@@ -168,13 +168,10 @@ void CCollisionPrimitive::InitEndTypes() {
}
void CCollisionPrimitive::InitBeginColliders() {
sTableOfCollidables.reset(new std::vector<ComparisonFunc>());
sTableOfBooleanCollidables.reset(new std::vector<BooleanComparisonFunc>());
sTableOfMovingCollidables.reset(new std::vector<MovingComparisonFunc>());
size_t tableSz = sCollisionTypeList->size() * sCollisionTypeList->size();
sTableOfCollidables->resize(tableSz);
sTableOfBooleanCollidables->resize(tableSz);
sTableOfMovingCollidables->resize(tableSz);
const size_t tableSz = sCollisionTypeList->size() * sCollisionTypeList->size();
sTableOfCollidables = std::make_unique<std::vector<ComparisonFunc>>(tableSz);
sTableOfBooleanCollidables = std::make_unique<std::vector<BooleanComparisonFunc>>(tableSz);
sTableOfMovingCollidables = std::make_unique<std::vector<MovingComparisonFunc>>(tableSz);
sCollidersAdding = true;
InternalColliders::AddColliders();
}