Use std::make_unique where it makes sense to

(and improve some other unique_ptr initializations).

Adapted from delroth's pull request.
This commit is contained in:
Tillmann Karras 2014-05-06 12:35:50 +02:00
parent 81d4d7368a
commit 452cdefaa3
3 changed files with 8 additions and 8 deletions

View File

@ -223,7 +223,7 @@ namespace JitILProfiler
std::unique_ptr<JitILProfilerFinalizer> finalizer; std::unique_ptr<JitILProfilerFinalizer> finalizer;
static void Init() static void Init()
{ {
finalizer = std::unique_ptr<JitILProfilerFinalizer>(new JitILProfilerFinalizer); finalizer.reset(new JitILProfilerFinalizer());
} }
static void Shutdown() static void Shutdown()
{ {

View File

@ -1280,7 +1280,7 @@ void IRBuilder::WriteToFile(u64 codeHash) {
_assert_(sizeof(opcodeNames) / sizeof(opcodeNames[0]) == Int3 + 1); _assert_(sizeof(opcodeNames) / sizeof(opcodeNames[0]) == Int3 + 1);
if (!writer.get()) { if (!writer.get()) {
writer = std::unique_ptr<Writer>(new Writer); writer.reset(new Writer());
} }
FILE* const file = writer->file.GetHandle(); FILE* const file = writer->file.GetHandle();

View File

@ -44,6 +44,7 @@
#include "Common/FileSearch.h" #include "Common/FileSearch.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
#include "Common/StdMakeUnique.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/SysConf.h" #include "Common/SysConf.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
@ -555,14 +556,13 @@ void CGameListCtrl::ScanForISOs()
if (dialog.WasCancelled()) if (dialog.WasCancelled())
break; break;
std::unique_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i])); auto iso_file = std::make_unique<GameListItem>(rFilenames[i]);
const GameListItem& ISOFile = *iso_file;
if (ISOFile.IsValid()) if (iso_file->IsValid())
{ {
bool list = true; bool list = true;
switch (ISOFile.GetPlatform()) switch(iso_file->GetPlatform())
{ {
case GameListItem::WII_DISC: case GameListItem::WII_DISC:
if (!SConfig::GetInstance().m_ListWii) if (!SConfig::GetInstance().m_ListWii)
@ -578,7 +578,7 @@ void CGameListCtrl::ScanForISOs()
break; break;
} }
switch (ISOFile.GetCountry()) switch(iso_file->GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_TAIWAN:
if (!SConfig::GetInstance().m_ListTaiwan) if (!SConfig::GetInstance().m_ListTaiwan)
@ -621,7 +621,7 @@ void CGameListCtrl::ScanForISOs()
for (const auto& drive : drives) for (const auto& drive : drives)
{ {
std::unique_ptr<GameListItem> gli(new GameListItem(drive)); auto gli = std::make_unique<GameListItem>(drive);
if (gli->IsValid()) if (gli->IsValid())
m_ISOFiles.push_back(gli.release()); m_ISOFiles.push_back(gli.release());