MEGASignatureDB: Move objects where applicable

Signatures during loading and strings during reference retrieval can be
moved.
This commit is contained in:
Lioncash 2017-03-28 15:59:08 -04:00
parent c0171975ea
commit eec4b705d5
1 changed files with 5 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include <fstream> #include <fstream>
#include <limits> #include <limits>
#include <sstream> #include <sstream>
#include <utility>
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
@ -91,7 +92,7 @@ bool GetRefs(MEGASignature* sig, std::istringstream* iss)
WARN_LOG(OSHLE, "MEGA database failed to parse reference %u name", ref_count); WARN_LOG(OSHLE, "MEGA database failed to parse reference %u name", ref_count);
return false; return false;
} }
sig->refs.emplace_back(static_cast<u32>(offset), ref); sig->refs.emplace_back(static_cast<u32>(offset), std::move(ref));
ref_count += 1; ref_count += 1;
num.clear(); num.clear();
@ -120,12 +121,13 @@ MEGASignatureDB::~MEGASignatureDB() = default;
bool MEGASignatureDB::Load(const std::string& file_path) bool MEGASignatureDB::Load(const std::string& file_path)
{ {
std::string line;
std::ifstream ifs; std::ifstream ifs;
OpenFStream(ifs, file_path, std::ios_base::in); OpenFStream(ifs, file_path, std::ios_base::in);
if (!ifs) if (!ifs)
return false; return false;
std::string line;
for (size_t i = 1; std::getline(ifs, line); ++i) for (size_t i = 1; std::getline(ifs, line); ++i)
{ {
std::istringstream iss(line); std::istringstream iss(line);
@ -133,7 +135,7 @@ bool MEGASignatureDB::Load(const std::string& file_path)
if (GetCode(&sig, &iss) && GetName(&sig, &iss) && GetRefs(&sig, &iss)) if (GetCode(&sig, &iss) && GetName(&sig, &iss) && GetRefs(&sig, &iss))
{ {
m_signatures.push_back(sig); m_signatures.push_back(std::move(sig));
} }
else else
{ {