StringUtil: Make SplitString return by value

Simpler usage.
This commit is contained in:
Léo Lam
2017-06-11 16:33:10 +02:00
parent 937d72e591
commit 17ef4c8046
11 changed files with 19 additions and 34 deletions

View File

@ -175,8 +175,6 @@ std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_in
continue;
}
std::vector<std::string> pieces;
// Check if the line is a name of the code
if (line[0] == '$')
{
@ -199,7 +197,7 @@ std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_in
}
else
{
SplitString(line, ' ', pieces);
std::vector<std::string> pieces = SplitString(line, ' ');
// Check if the AR code is decrypted
if (pieces.size() == 2 && pieces[0].size() == 8 && pieces[1].size() == 8)
@ -225,7 +223,7 @@ std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_in
}
else
{
SplitString(line, '-', pieces);
pieces = SplitString(line, '-');
if (pieces.size() == 3 && pieces[0].size() == 4 && pieces[1].size() == 4 &&
pieces[2].size() == 5)
{

View File

@ -686,10 +686,8 @@ void SConfig::LoadUSBPassthroughSettings(IniFile& ini)
IniFile::Section* section = ini.GetOrCreateSection("USBPassthrough");
m_usb_passthrough_devices.clear();
std::string devices_string;
std::vector<std::string> pairs;
section->Get("Devices", &devices_string, "");
SplitString(devices_string, ',', pairs);
for (const auto& pair : pairs)
for (const auto& pair : SplitString(devices_string, ','))
{
const auto index = pair.find(':');
if (index == std::string::npos)

View File

@ -520,9 +520,7 @@ void BluetoothReal::LoadLinkKeys()
const std::string& entries = SConfig::GetInstance().m_bt_passthrough_link_keys;
if (entries.empty())
return;
std::vector<std::string> pairs;
SplitString(entries, ',', pairs);
for (const auto& pair : pairs)
for (const auto& pair : SplitString(entries, ','))
{
const auto index = pair.find('=');
if (index == std::string::npos)

View File

@ -86,8 +86,7 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
line[loc] = ':';
}
std::vector<std::string> items;
SplitString(line, ':', items);
const std::vector<std::string> items = SplitString(line, ':');
if (items.size() >= 3)
{