Modernize std::binary_search with ranges

In VolumeVerifier.cpp, constructing a `std::string_view` of the volume's GameID is unnecessary, as `std::`(`ranges::`)`binary_search` supports heterogeneous lookup. The usage in GameFile.cpp is a perfect example.
This commit is contained in:
mitaclaw
2024-09-28 22:30:41 -07:00
parent 01d0bdf1bb
commit 728663bdc0
3 changed files with 4 additions and 8 deletions

View File

@ -722,8 +722,7 @@ bool VolumeVerifier::ShouldHaveChannelPartition() const
};
static_assert(std::ranges::is_sorted(channel_discs));
return std::binary_search(channel_discs.cbegin(), channel_discs.cend(),
std::string_view(m_volume.GetGameID()));
return std::ranges::binary_search(channel_discs, m_volume.GetGameID());
}
bool VolumeVerifier::ShouldHaveInstallPartition() const
@ -755,8 +754,7 @@ bool VolumeVerifier::ShouldBeDualLayer() const
};
static_assert(std::ranges::is_sorted(dual_layer_discs));
return std::binary_search(dual_layer_discs.cbegin(), dual_layer_discs.cend(),
std::string_view(m_volume.GetGameID()));
return std::ranges::binary_search(dual_layer_discs, m_volume.GetGameID());
}
void VolumeVerifier::CheckVolumeSize()