mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 03: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:
@@ -11,15 +11,17 @@ CSimplePool::CSimplePool(IFactory& factory)
|
||||
CSimplePool::~CSimplePool() { assert(x8_resources.empty() && "Dangling CSimplePool resources detected"); }
|
||||
|
||||
CToken CSimplePool::GetObj(const SObjectTag& tag, const CVParamTransfer& paramXfer) {
|
||||
if (!tag)
|
||||
if (!tag) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto iter = x8_resources.find(tag);
|
||||
if (iter != x8_resources.end())
|
||||
const auto iter = x8_resources.find(tag);
|
||||
if (iter != x8_resources.end()) {
|
||||
return CToken(iter->second);
|
||||
}
|
||||
|
||||
CObjectReference* ret = new CObjectReference(*this, std::unique_ptr<IObj>(), tag, paramXfer);
|
||||
x8_resources.emplace(std::make_pair<SObjectTag, CObjectReference*>((SObjectTag)tag, std::move(ret)));
|
||||
auto* const ret = new CObjectReference(*this, nullptr, tag, paramXfer);
|
||||
x8_resources.emplace(tag, ret);
|
||||
return CToken(ret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user