mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-02 15:45:58 +00:00
Simplify std::find
with Common::Contains
In NandPaths.cpp, the `std::initializer_list<char>` of illegal characters has been turned into a `char[]` (similar to the one in GameList.cpp). The reverse iteration in ResourcePack.cpp seemed to provide no benefits, and doing without it it seemed to have no ill effects.
This commit is contained in:
parent
6f10acea3f
commit
110d32729e
16 changed files with 43 additions and 51 deletions
|
@ -43,6 +43,7 @@
|
|||
#include <QUrl>
|
||||
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/Contains.h"
|
||||
#include "Common/FileUtil.h"
|
||||
|
||||
#include "Core/Config/MainSettings.h"
|
||||
|
@ -805,8 +806,7 @@ bool GameList::AddShortcutToDesktop()
|
|||
// Sanitize the string by removing all characters that cannot be used in NTFS file names
|
||||
std::erase_if(game_name, [](char ch) {
|
||||
static constexpr char illegal_characters[] = {'<', '>', ':', '\"', '/', '\\', '|', '?', '*'};
|
||||
return std::find(std::begin(illegal_characters), std::end(illegal_characters), ch) !=
|
||||
std::end(illegal_characters);
|
||||
return Common::Contains(illegal_characters, ch);
|
||||
});
|
||||
|
||||
std::wstring desktop_path = std::wstring(desktop.get()) + UTF8ToTStr("\\" + game_name + ".lnk");
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Common/Contains.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
|
||||
|
@ -108,7 +109,7 @@ void ChunkedProgressDialog::show(const QString& title, const u64 data_size,
|
|||
|
||||
for (const auto* player : client->GetPlayers())
|
||||
{
|
||||
if (std::find(players.begin(), players.end(), player->pid) == players.end())
|
||||
if (!Common::Contains(players, player->pid))
|
||||
continue;
|
||||
|
||||
m_progress_bars[player->pid] = new QProgressBar;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "AudioCommon/AudioCommon.h"
|
||||
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Common/Contains.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
|
@ -296,7 +297,7 @@ void Settings::AddPath(const QString& qpath)
|
|||
std::string path = qpath.toStdString();
|
||||
std::vector<std::string> paths = Config::GetIsoPaths();
|
||||
|
||||
if (std::find(paths.begin(), paths.end(), path) != paths.end())
|
||||
if (Common::Contains(paths, path))
|
||||
return;
|
||||
|
||||
paths.emplace_back(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue