Skip to content

Commit

Permalink
Merge pull request #2013 from lioncash/emplace
Browse files Browse the repository at this point in the history
Use emplace_* functions where in-place construction is preferable
  • Loading branch information
degasus committed Feb 4, 2015
2 parents 012a4c1 + e076791 commit 235fa05
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Common/IniFile.cpp
Expand Up @@ -203,7 +203,7 @@ IniFile::Section* IniFile::GetOrCreateSection(const std::string& sectionName)
Section* section = GetSection(sectionName);
if (!section)
{
sections.push_back(Section(sectionName));
sections.emplace_back(sectionName);
section = &sections.back();
}
return section;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/NandPaths.cpp
Expand Up @@ -101,7 +101,7 @@ void ReadReplacements(replace_v& replacements)
std::string replacement;

while (f >> letter >> replacement && replacement.size())
replacements.push_back(std::make_pair(letter, replacement));
replacements.emplace_back(letter, replacement);
}

}
2 changes: 1 addition & 1 deletion Source/Core/Core/DSP/LabelMap.cpp
Expand Up @@ -33,7 +33,7 @@ void LabelMap::RegisterLabel(const std::string &label, u16 lval, LabelType type)
label.c_str(), lval, old_value);
DeleteLabel(label);
}
labels.push_back(label_t(label, lval, type));
labels.emplace_back(label, lval, type);
}

void LabelMap::DeleteLabel(const std::string &label)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GCMemcardDirectory.cpp
Expand Up @@ -434,7 +434,7 @@ inline s32 GCMemcardDirectory::SaveAreaRW(u32 block, bool writing)
int num_blocks = BE16(m_saves[i].m_gci_header.BlockCount);
while (num_blocks)
{
m_saves[i].m_save_data.push_back(GCMBlock());
m_saves[i].m_save_data.emplace_back();
num_blocks--;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
Expand Up @@ -186,7 +186,7 @@ namespace JitILProfiler
static Block& Add(u64 codeHash)
{
const u32 _blockIndex = (u32)blocks.size();
blocks.push_back(Block());
blocks.emplace_back();
Block& block = blocks.back();
block.index = _blockIndex;
block.codeHash = codeHash;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitInterface.cpp
Expand Up @@ -153,7 +153,7 @@ namespace JitInterface
u64 timecost = block->ticCounter;
// Todo: tweak.
if (block->runCount >= 1)
stats.push_back(BlockStat(i, cost));
stats.emplace_back(i, cost);
cost_sum += cost;
timecost_sum += timecost;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/PPCAnalyst.cpp
Expand Up @@ -175,7 +175,7 @@ bool AnalyzeFunction(u32 startAddr, Symbol &func, int max_size)
if (target != INVALID_TARGET && instr.LK)
{
//we found a branch-n-link!
func.calls.push_back(SCall(target,addr));
func.calls.emplace_back(target, addr);
func.flags &= ~FFLAG_LEAF;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/ARCodeAddEdit.cpp
Expand Up @@ -113,7 +113,7 @@ void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
u32 addr = std::stoul(pieces[0], nullptr, 16);
u32 value = std::stoul(pieces[1], nullptr, 16);

decryptedLines.push_back(ActionReplay::AREntry(addr, value));
decryptedLines.emplace_back(addr, value);
continue;
}
else if (pieces.size() == 1)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/PatchAddEdit.cpp
Expand Up @@ -48,7 +48,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
if (_selection == -1)
{
tempEntries.clear();
tempEntries.push_back(PatchEngine::PatchEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000));
tempEntries.emplace_back(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000);
}
else
{
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/VideoCommon/FramebufferManagerBase.cpp
Expand Up @@ -128,9 +128,7 @@ void FramebufferManagerBase::CopyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHe
if (m_virtualXFBList.size() < MAX_VIRTUAL_XFB)
{
// create a new Virtual XFB and place it at the front of the list
VirtualXFB v;
memset(&v, 0, sizeof v);
m_virtualXFBList.push_front(v);
m_virtualXFBList.emplace_front();
vxfb = m_virtualXFBList.begin();
}
else
Expand Down
12 changes: 7 additions & 5 deletions Source/Core/VideoCommon/FramebufferManagerBase.h
Expand Up @@ -57,14 +57,16 @@ class FramebufferManagerBase
protected:
struct VirtualXFB
{
VirtualXFB() : xfbSource(nullptr) {}
VirtualXFB()
{
}

// Address and size in GameCube RAM
u32 xfbAddr;
u32 xfbWidth;
u32 xfbHeight;
u32 xfbAddr = 0;
u32 xfbWidth = 0;
u32 xfbHeight = 0;

XFBSourceBase *xfbSource;
XFBSourceBase* xfbSource = nullptr;
};

typedef std::list<VirtualXFB> VirtualXFBListType;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/PostProcessing.cpp
Expand Up @@ -129,7 +129,7 @@ void PostProcessingShaderConfiguration::LoadOptions(const std::string& code)
IniFile::ParseLine(line, &key, &value);

if (!(key == "" && value == ""))
current_strings->m_options.push_back(std::make_pair(key, value));
current_strings->m_options.emplace_back(key, value);
}
}
}
Expand Down

0 comments on commit 235fa05

Please sign in to comment.