DiscIO/VolumeVerifier: Take std::string by value in AddProblem()

This allows both std::moving into the function and moving the parameter
from within the function, potentially avoiding an unnecessary copy.
This commit is contained in:
Lioncash 2019-05-27 10:12:20 -04:00
parent a1f77fd14b
commit 0ccaa2b5d6
2 changed files with 18 additions and 18 deletions

View File

@ -191,9 +191,9 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition)) if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition))
{ {
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("The H3 hash table for the %s partition is not correct.").c_str(), name.c_str()); GetStringT("The H3 hash table for the %s partition is not correct.").c_str(), name.c_str());
AddProblem(Severity::Low, text); AddProblem(Severity::Low, std::move(text));
} }
bool invalid_disc_header = false; bool invalid_disc_header = false;
@ -224,18 +224,18 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
// This can happen when certain programs that create WBFS files scrub the entirety of // This can happen when certain programs that create WBFS files scrub the entirety of
// the Masterpiece partitions in Super Smash Bros. Brawl without removing them from // the Masterpiece partitions in Super Smash Bros. Brawl without removing them from
// the partition table. https://bugs.dolphin-emu.org/issues/8733 // the partition table. https://bugs.dolphin-emu.org/issues/8733
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("The %s partition does not seem to contain valid data.").c_str(), name.c_str()); GetStringT("The %s partition does not seem to contain valid data.").c_str(), name.c_str());
AddProblem(severity, text); AddProblem(severity, std::move(text));
return false; return false;
} }
const DiscIO::FileSystem* filesystem = m_volume.GetFileSystem(partition); const DiscIO::FileSystem* filesystem = m_volume.GetFileSystem(partition);
if (!filesystem) if (!filesystem)
{ {
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("The %s partition does not have a valid file system.").c_str(), name.c_str()); GetStringT("The %s partition does not have a valid file system.").c_str(), name.c_str());
AddProblem(severity, text); AddProblem(severity, std::move(text));
return false; return false;
} }
@ -306,7 +306,7 @@ std::string VolumeVerifier::GetPartitionName(std::optional<u32> type) const
return name; return name;
} }
void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, const std::string& error_text) void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, std::string error_text)
{ {
IOS::HLE::Kernel ios; IOS::HLE::Kernel ios;
const auto es = ios.GetES(); const auto es = ios.GetES();
@ -321,7 +321,7 @@ void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, const std:
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore, IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
m_volume.GetTMD(partition), cert_chain)) m_volume.GetTMD(partition), cert_chain))
{ {
AddProblem(Severity::Low, error_text); AddProblem(Severity::Low, std::move(error_text));
} }
} }
@ -377,7 +377,7 @@ void VolumeVerifier::CheckDiscSize()
{ {
const bool second_layer_missing = const bool second_layer_missing =
biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE; biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
const std::string text = std::string text =
second_layer_missing ? second_layer_missing ?
GetStringT( GetStringT(
"This disc image is too small and lacks some data. The problem is most likely that " "This disc image is too small and lacks some data. The problem is most likely that "
@ -385,7 +385,7 @@ void VolumeVerifier::CheckDiscSize()
GetStringT( GetStringT(
"This disc image is too small and lacks some data. If your dumping program saved " "This disc image is too small and lacks some data. If your dumping program saved "
"the disc image as several parts, you need to merge them into one file."); "the disc image as several parts, you need to merge them into one file.");
AddProblem(Severity::High, text); AddProblem(Severity::High, std::move(text));
return; return;
} }
@ -819,10 +819,10 @@ void VolumeVerifier::Finish()
if (pair.second > 0) if (pair.second > 0)
{ {
const std::string name = GetPartitionName(m_volume.GetPartitionType(pair.first)); const std::string name = GetPartitionName(m_volume.GetPartitionType(pair.first));
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), pair.second, GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), pair.second,
name.c_str()); name.c_str());
AddProblem(Severity::Medium, text); AddProblem(Severity::Medium, std::move(text));
} }
} }
@ -831,10 +831,10 @@ void VolumeVerifier::Finish()
if (pair.second > 0) if (pair.second > 0)
{ {
const std::string name = GetPartitionName(m_volume.GetPartitionType(pair.first)); const std::string name = GetPartitionName(m_volume.GetPartitionType(pair.first));
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(), GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(),
pair.second, name.c_str()); pair.second, name.c_str());
AddProblem(Severity::Low, text); AddProblem(Severity::Low, std::move(text));
} }
} }
@ -904,9 +904,9 @@ const VolumeVerifier::Result& VolumeVerifier::GetResult() const
return m_result; return m_result;
} }
void VolumeVerifier::AddProblem(Severity severity, const std::string& text) void VolumeVerifier::AddProblem(Severity severity, std::string text)
{ {
m_result.problems.emplace_back(Problem{severity, text}); m_result.problems.emplace_back(Problem{severity, std::move(text)});
} }
} // namespace DiscIO } // namespace DiscIO

View File

@ -90,7 +90,7 @@ private:
void CheckPartitions(); void CheckPartitions();
bool CheckPartition(const Partition& partition); // Returns false if partition should be ignored bool CheckPartition(const Partition& partition); // Returns false if partition should be ignored
std::string GetPartitionName(std::optional<u32> type) const; std::string GetPartitionName(std::optional<u32> type) const;
void CheckCorrectlySigned(const Partition& partition, const std::string& error_text); void CheckCorrectlySigned(const Partition& partition, std::string error_text);
bool IsDebugSigned() const; bool IsDebugSigned() const;
bool ShouldHaveChannelPartition() const; bool ShouldHaveChannelPartition() const;
bool ShouldHaveInstallPartition() const; bool ShouldHaveInstallPartition() const;
@ -103,7 +103,7 @@ private:
void SetUpHashing(); void SetUpHashing();
bool CheckContentIntegrity(const IOS::ES::Content& content); bool CheckContentIntegrity(const IOS::ES::Content& content);
void AddProblem(Severity severity, const std::string& text); void AddProblem(Severity severity, std::string text);
const Volume& m_volume; const Volume& m_volume;
Result m_result; Result m_result;