Implemented suggestions from clang-tidy-16 (mostly emplace vs. push_back).

This commit is contained in:
Stephen Anthony 2022-12-01 15:39:21 -03:30
parent e63ce4935c
commit f9edb95a6e
14 changed files with 100 additions and 99 deletions

View File

@ -83,8 +83,8 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
// Inputbox which will pop up when adding/editing a cheat
StringList labels;
labels.push_back("Name ");
labels.push_back("Code (hex) ");
labels.emplace_back("Name ");
labels.emplace_back("Code (hex) ");
myCheatInput = make_unique<InputTextDialog>(this, font, labels, "Cheat code");
myCheatInput->setTarget(this);

View File

@ -48,8 +48,9 @@ namespace {
private:
KeyValueRepositoryAtomic& myKvr;
const string& myKey;
// NOLINT: cppcoreguidelines-avoid-const-or-ref-data-members
KeyValueRepositoryAtomic& myKvr; // NOLINT
const string& myKey; // NOLINT
};
} // namespace

View File

@ -1541,23 +1541,23 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const
// First scan system equates
for(uInt16 addr = 0x00; addr <= 0x0F; ++addr)
if(ourTIAMnemonicR[addr] && BSPF::matchesIgnoreCase(ourTIAMnemonicR[addr], in))
completions.push_back(ourTIAMnemonicR[addr]);
completions.emplace_back(ourTIAMnemonicR[addr]);
for(uInt16 addr = 0x00; addr <= 0x3F; ++addr)
if(ourTIAMnemonicW[addr] && BSPF::matchesIgnoreCase(ourTIAMnemonicW[addr], in))
completions.push_back(ourTIAMnemonicW[addr]);
completions.emplace_back(ourTIAMnemonicW[addr]);
for(uInt16 addr = 0; addr <= 0x29F-0x280; ++addr)
if(ourIOMnemonic[addr] && BSPF::matchesIgnoreCase(ourIOMnemonic[addr], in))
completions.push_back(ourIOMnemonic[addr]);
completions.emplace_back(ourIOMnemonic[addr]);
for(uInt16 addr = 0; addr <= 0x7F; ++addr)
if(ourZPMnemonic[addr] && BSPF::matchesIgnoreCase(ourZPMnemonic[addr], in))
completions.push_back(ourZPMnemonic[addr]);
completions.emplace_back(ourZPMnemonic[addr]);
// Now scan user-defined labels
for(const auto& iter: myUserAddresses)
{
const char* const l = iter.first.c_str();
if(BSPF::matchesCamelCase(l, in))
completions.push_back(l);
completions.emplace_back(l);
}
}

View File

@ -901,12 +901,12 @@ void Debugger::getCompletions(const char* in, StringList& list) const
{
const char* const l = iter.first.c_str();
if(BSPF::matchesCamelCase(l, in))
list.push_back(l);
list.emplace_back(l);
}
for(const auto& reg: ourPseudoRegisters)
if(BSPF::matchesCamelCase(reg.name, in))
list.push_back(reg.name);
list.emplace_back(reg.name);
}
}

View File

@ -63,8 +63,8 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
StringList off, on;
for(int i = 0; i < 8; ++i)
{
off.push_back("0");
on.push_back("1");
off.emplace_back("0");
on.emplace_back("1");
}
StringList labels;
@ -91,14 +91,14 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
// SWCHA bits in 'peek' mode
xpos = 10; ypos += lineHeight + 5;
labels.clear();
labels.push_back("Left right");
labels.push_back("Left left");
labels.push_back("Left down");
labels.push_back("Left up");
labels.push_back("Right right");
labels.push_back("Right left");
labels.push_back("Right down");
labels.push_back("Right up");
labels.emplace_back("Left right");
labels.emplace_back("Left left");
labels.emplace_back("Left down");
labels.emplace_back("Left up");
labels.emplace_back("Right right");
labels.emplace_back("Right left");
labels.emplace_back("Right down");
labels.emplace_back("Right up");
CREATE_IO_REGS("SWCHA(R)", mySWCHAReadBits, kSWCHARBitsID, true)
// SWCHB bits in 'poke' mode
@ -113,14 +113,14 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
// SWCHB bits in 'peek' mode
xpos = 10; ypos += lineHeight + 5;
labels.clear();
labels.push_back("Right difficulty");
labels.push_back("Left difficulty");
labels.push_back("");
labels.push_back("");
labels.push_back("Color/B+W");
labels.push_back("");
labels.push_back("Select");
labels.push_back("Reset");
labels.emplace_back("Right difficulty");
labels.emplace_back("Left difficulty");
labels.emplace_back("");
labels.emplace_back("");
labels.emplace_back("Color/B+W");
labels.emplace_back("");
labels.emplace_back("Select");
labels.emplace_back("Reset");
CREATE_IO_REGS("SWCHB(R)", mySWCHBReadBits, kSWCHBRBitsID, true)
// Timer registers (R/W)

View File

@ -38,8 +38,8 @@ ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font,
int size = _rows * _cols;
while(size--)
{
_offList.push_back("0");
_onList.push_back("1");
_offList.emplace_back("0");
_onList.emplace_back("1");
_stateList.push_back(false);
_changedList.push_back(false);
}

View File

@ -1543,11 +1543,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
myOSystem.settings().getBool("dev.settings") ? "dev.timemachine" : "plr.timemachine");
msg.push_back("Do you really want to exit emulation?");
msg.emplace_back("Do you really want to exit emulation?");
if (saveOnExit != "all" || !activeTM)
{
msg.push_back("");
msg.push_back("You will lose all your progress.");
msg.emplace_back("");
msg.emplace_back("You will lose all your progress.");
}
MessageMenu::setMessage("Exit Emulation", msg, true);
enterMenuMode(EventHandlerState::MESSAGEMENU);
@ -2330,7 +2330,7 @@ StringList EventHandler::getComboListForEvent(Event::Type event) const
}
// Make sure entries are 1-to-1, using '-1' to indicate Event::NoType
if(i == l.size())
l.push_back("-1");
l.emplace_back("-1");
}
}
return l;

View File

@ -441,7 +441,7 @@ void Dialog::addToFocusList(const WidgetArray& list, const TabWidget* w, int tab
{
// Make sure the array is large enough
while(focus.size() <= id)
focus.push_back(Focus());
focus.emplace_back();
Vec::append(focus[id].list, list);
}
@ -459,9 +459,9 @@ void Dialog::addTabWidget(TabWidget* w)
// Make sure the array is large enough
const uInt32 id = w->getID();
while(_myTabList.size() < id)
_myTabList.push_back(TabFocus());
_myTabList.emplace_back();
_myTabList.push_back(TabFocus(w));
_myTabList.emplace_back(w);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -509,9 +509,9 @@ bool HighScoresDialog::handleDirty()
{
StringList msg;
msg.push_back("Do you want to save the changes");
msg.push_back("for this variation?");
msg.push_back("");
msg.emplace_back("Do you want to save the changes");
msg.emplace_back("for this variation?");
msg.emplace_back("");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, _max_w, _max_h, kConfirmSave, kCancelSave,
"Yes", "No", "Save High Scores", false);

View File

@ -783,13 +783,13 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
if(!myConfirmMsg)
{
StringList msg;
msg.push_back("This operation cannot be undone.");
msg.push_back("All data stored on your AtariVox");
msg.push_back("or SaveKey will be erased!");
msg.push_back("");
msg.push_back("If you are sure you want to erase");
msg.push_back("the data, click 'OK', otherwise ");
msg.push_back("click 'Cancel'.");
msg.emplace_back("This operation cannot be undone.");
msg.emplace_back("All data stored on your AtariVox");
msg.emplace_back("or SaveKey will be erased!");
msg.emplace_back("");
msg.emplace_back("If you are sure you want to erase");
msg.emplace_back("the data, click 'OK', otherwise ");
msg.emplace_back("click 'Cancel'.");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, instance().frameBuffer().font(), msg,
myMaxWidth, myMaxHeight, kConfirmEEEraseCmd,

View File

@ -1166,64 +1166,64 @@ void LauncherDialog::openContextMenu(int x, int y)
if(!currentNode().isDirectory())
{
if(myList->isUserDir(currentNode().getName()))
items.push_back(ContextItem("Remove all from favorites", "removefavorites"));
items.emplace_back("Remove all from favorites", "removefavorites");
if(myList->isPopularDir(currentNode().getName()))
items.push_back(ContextItem("Remove all from most popular", "removepopular"));
items.emplace_back("Remove all from most popular", "removepopular");
if(myList->isRecentDir(currentNode().getName()))
items.push_back(ContextItem("Remove all from recently played", "removerecent"));
items.emplace_back("Remove all from recently played", "removerecent");
if(myList->inRecentDir())
items.push_back(ContextItem("Remove from recently played", "Ctrl+X", "remove"));
items.emplace_back("Remove from recently played", "Ctrl+X", "remove");
if(myList->inPopularDir())
items.push_back(ContextItem("Remove from most popular", "Ctrl+X", "remove"));
items.emplace_back("Remove from most popular", "Ctrl+X", "remove");
}
if((currentNode().isDirectory() && currentNode().getName() != "..")
|| Bankswitch::isValidRomName(currentNode()))
items.push_back(ContextItem(myList->isUserFavorite(myList->selected().getPath())
items.emplace_back(myList->isUserFavorite(myList->selected().getPath())
? "Remove from favorites"
: "Add to favorites", "Ctrl+F", "favorite"));
: "Add to favorites", "Ctrl+F", "favorite");
}
if(!currentNode().isDirectory() && Bankswitch::isValidRomName(currentNode()))
{
items.push_back(ContextItem("Game properties" + ELLIPSIS, "Ctrl+G", "properties"));
items.push_back(ContextItem("Power-on options" + ELLIPSIS, "Ctrl+P", "override"));
items.emplace_back("Game properties" + ELLIPSIS, "Ctrl+G", "properties");
items.emplace_back("Power-on options" + ELLIPSIS, "Ctrl+P", "override");
if(instance().highScores().enabled())
items.push_back(ContextItem("High scores" + ELLIPSIS, "Ctrl+H", "highscores"));
items.emplace_back("High scores" + ELLIPSIS, "Ctrl+H", "highscores");
}
if(myUseMinimalUI)
{
#ifndef RETRON77
items.push_back(ContextItem(instance().settings().getBool("launchersubdirs")
items.emplace_back(instance().settings().getBool("launchersubdirs")
? "Exclude subdirectories"
: "Include subdirectories", "subdirs"));
items.push_back(ContextItem(instance().settings().getBool("launcherroms")
: "Include subdirectories", "subdirs");
items.emplace_back(instance().settings().getBool("launcherroms")
? "Show all files"
: "Show only ROMs", "showall"));
: "Show only ROMs", "showall");
#endif
items.push_back(ContextItem("Go to initial directory", "homedir"));
items.push_back(ContextItem("Go to parent directory", "prevdir"));
items.emplace_back("Go to initial directory", "homedir");
items.emplace_back("Go to parent directory", "prevdir");
#ifndef RETRON77
items.push_back(ContextItem("Reload listing", "reload"));
items.push_back(ContextItem("Options" + ELLIPSIS, "options"));
items.emplace_back("Reload listing", "reload");
items.emplace_back("Options" + ELLIPSIS, "options");
#else
items.push_back(ContextItem("Settings" + ELLIPSIS, "options"));
items.emplace_back("Settings" + ELLIPSIS, "options");
#endif
}
else
{
items.push_back(ContextItem(instance().settings().getBool("launcherextensions")
items.emplace_back(instance().settings().getBool("launcherextensions")
? "Disable file extensions"
: "Enable file extensions", "Ctrl+E", "extensions"));
: "Enable file extensions", "Ctrl+E", "extensions");
if(useFavorites && myList->inVirtualDir())
items.push_back(ContextItem(instance().settings().getBool("altsorting")
items.emplace_back(instance().settings().getBool("altsorting")
? "Normal sorting"
: "Alternative sorting", "Ctrl+S", "sorting"));
: "Alternative sorting", "Ctrl+S", "sorting");
//if(!instance().settings().getBool("launcherbuttons"))
//{
// items.push_back(ContextItem("Options" + ELLIPSIS, "Ctrl+O", "options"));
// items.emplace_back("Options" + ELLIPSIS, "Ctrl+O", "options");
//}
}
if(addCancel)
items.push_back(ContextItem("Cancel", "")); // closes the context menu and does nothing
items.emplace_back("Cancel", ""); // closes the context menu and does nothing
// Format items for menu
VariantList varItems;
@ -1382,10 +1382,10 @@ void LauncherDialog::removeAllFavorites()
{
StringList msg;
msg.push_back("This will remove ALL ROMs from");
msg.push_back("your 'Favorites' list!");
msg.push_back("");
msg.push_back("Are you sure?");
msg.emplace_back("This will remove ALL ROMs from");
msg.emplace_back("your 'Favorites' list!");
msg.emplace_back("");
msg.emplace_back("Are you sure?");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, _w, _h, kRmAllFav,
"Yes", "No", "Remove all Favorites", false);
@ -1397,10 +1397,10 @@ void LauncherDialog::removeAll(const string& name)
{
StringList msg;
msg.push_back("This will remove ALL ROMs from");
msg.push_back("your '" + name + "' list!");
msg.push_back("");
msg.push_back("Are you sure?");
msg.emplace_back("This will remove ALL ROMs from");
msg.emplace_back("your '" + name + "' list!");
msg.emplace_back("");
msg.emplace_back("Are you sure?");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, _w, _h, kRmAllPop,
"Yes", "No", "Remove all " + name, false);

View File

@ -177,13 +177,13 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
if(!myConfirmMsg)
{
StringList msg;
msg.push_back("This operation cannot be undone. Your ROMs");
msg.push_back("will be modified, and as such there is a chance");
msg.push_back("that files may be lost. You are recommended");
msg.push_back("to back up your files before proceeding.");
msg.push_back("");
msg.push_back("If you're sure you want to proceed with the");
msg.push_back("audit, click 'OK', otherwise click 'Cancel'.");
msg.emplace_back("This operation cannot be undone. Your ROMs");
msg.emplace_back("will be modified, and as such there is a chance");
msg.emplace_back("that files may be lost. You are recommended");
msg.emplace_back("to back up your files before proceeding.");
msg.emplace_back("");
msg.emplace_back("If you're sure you want to proceed with the");
msg.emplace_back("audit, click 'OK', otherwise click 'Cancel'.");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, _font, msg, myMaxWidth, myMaxHeight, kConfirmAuditCmd,
"OK", "Cancel", "ROM Audit", false);

View File

@ -412,15 +412,15 @@ void StellaSettingsDialog::switchSettingsMode()
{
StringList msg;
msg.push_back("Warning!");
msg.push_back("");
msg.push_back("Advanced settings should be");
msg.push_back("handled with care! When in");
msg.push_back("doubt, read the manual.");
msg.push_back("");
msg.push_back("If you are sure you want to");
msg.push_back("proceed with the switch, click");
msg.push_back("'OK', otherwise click 'Cancel'.");
msg.emplace_back("Warning!");
msg.emplace_back("");
msg.emplace_back("Advanced settings should be");
msg.emplace_back("handled with care! When in");
msg.emplace_back("doubt, read the manual.");
msg.emplace_back("");
msg.emplace_back("If you are sure you want to");
msg.emplace_back("proceed with the switch, click");
msg.emplace_back("'OK', otherwise click 'Cancel'.");
myConfirmMsg = make_unique<GUI::MessageBox>(this, _font, msg,
_w-16, _h, kConfirmSwitchCmd, "OK", "Cancel", "Switch settings mode", false);

View File

@ -66,9 +66,9 @@ int TabWidget::addTab(const string& title, int tabWidth)
const int newWidth = _font.getStringWidth(title) + 2 * kTabPadding;
if(tabWidth == AUTO_WIDTH)
_tabs.push_back(Tab(title, newWidth));
_tabs.emplace_back(title, newWidth);
else
_tabs.push_back(Tab(title, tabWidth));
_tabs.emplace_back(title, tabWidth);
const int numTabs = static_cast<int>(_tabs.size());
// Determine the new tab width