PatchEngine: Give Patch and PatchEntry default member initializers

Avoids potentially using the values uninitialized. While we're at it,
also drop the prefixed underscores from one of the constructors.
This commit is contained in:
Lioncash
2018-05-13 13:53:49 -04:00
parent 9d1157f695
commit a166cf2481
3 changed files with 10 additions and 14 deletions

View File

@ -24,19 +24,19 @@ extern const char* PatchTypeStrings[];
struct PatchEntry struct PatchEntry
{ {
PatchEntry() {} PatchEntry() = default;
PatchEntry(PatchType _t, u32 _addr, u32 _value) : type(_t), address(_addr), value(_value) {} PatchEntry(PatchType t, u32 addr, u32 value_) : type(t), address(addr), value(value_) {}
PatchType type; PatchType type = PatchType::PATCH_8BIT;
u32 address; u32 address = 0;
u32 value; u32 value = 0;
}; };
struct Patch struct Patch
{ {
std::string name; std::string name;
std::vector<PatchEntry> entries; std::vector<PatchEntry> entries;
bool active; bool active = false;
bool user_defined; // False if this code is shipped with Dolphin. bool user_defined = false; // False if this code is shipped with Dolphin.
}; };
int GetSpeedhackCycles(const u32 addr); int GetSpeedhackCycles(const u32 addr);

View File

@ -79,11 +79,7 @@ void NewPatchDialog::ConnectWidgets()
void NewPatchDialog::AddEntry() void NewPatchDialog::AddEntry()
{ {
PatchEngine::PatchEntry entry; m_patch.entries.emplace_back();
entry.type = PatchEngine::PATCH_8BIT;
entry.address = entry.value = 0;
m_patch.entries.push_back(entry);
m_entry_layout->addWidget(CreateEntry(static_cast<int>(m_patch.entries.size() - 1))); m_entry_layout->addWidget(CreateEntry(static_cast<int>(m_patch.entries.size() - 1)));
} }

View File

@ -42,7 +42,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
if (_selection == -1) if (_selection == -1)
{ {
tempEntries.clear(); tempEntries.clear();
tempEntries.emplace_back(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000); tempEntries.emplace_back();
} }
else else
{ {
@ -165,7 +165,7 @@ void CPatchAddEdit::AddEntry(wxCommandEvent& event)
if (!UpdateTempEntryData(itCurEntry)) if (!UpdateTempEntryData(itCurEntry))
return; return;
PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000); PatchEngine::PatchEntry peEmptyEntry;
++itCurEntry; ++itCurEntry;
currentItem++; currentItem++;
itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry); itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);