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:
parent
01d0bdf1bb
commit
728663bdc0
|
@ -722,8 +722,7 @@ bool VolumeVerifier::ShouldHaveChannelPartition() const
|
||||||
};
|
};
|
||||||
static_assert(std::ranges::is_sorted(channel_discs));
|
static_assert(std::ranges::is_sorted(channel_discs));
|
||||||
|
|
||||||
return std::binary_search(channel_discs.cbegin(), channel_discs.cend(),
|
return std::ranges::binary_search(channel_discs, m_volume.GetGameID());
|
||||||
std::string_view(m_volume.GetGameID()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VolumeVerifier::ShouldHaveInstallPartition() const
|
bool VolumeVerifier::ShouldHaveInstallPartition() const
|
||||||
|
@ -755,8 +754,7 @@ bool VolumeVerifier::ShouldBeDualLayer() const
|
||||||
};
|
};
|
||||||
static_assert(std::ranges::is_sorted(dual_layer_discs));
|
static_assert(std::ranges::is_sorted(dual_layer_discs));
|
||||||
|
|
||||||
return std::binary_search(dual_layer_discs.cbegin(), dual_layer_discs.cend(),
|
return std::ranges::binary_search(dual_layer_discs, m_volume.GetGameID());
|
||||||
std::string_view(m_volume.GetGameID()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeVerifier::CheckVolumeSize()
|
void VolumeVerifier::CheckVolumeSize()
|
||||||
|
|
|
@ -616,8 +616,7 @@ bool GameFile::CheckIfTwoDiscGame(const std::string& game_id) const
|
||||||
static_assert(std::ranges::is_sorted(two_disc_game_id_prefixes));
|
static_assert(std::ranges::is_sorted(two_disc_game_id_prefixes));
|
||||||
|
|
||||||
std::string_view game_id_prefix(game_id.data(), GAME_ID_PREFIX_SIZE);
|
std::string_view game_id_prefix(game_id.data(), GAME_ID_PREFIX_SIZE);
|
||||||
return std::binary_search(two_disc_game_id_prefixes.begin(), two_disc_game_id_prefixes.end(),
|
return std::ranges::binary_search(two_disc_game_id_prefixes, game_id_prefix);
|
||||||
game_id_prefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameFile::GetNetPlayName(const Core::TitleDatabase& title_database) const
|
std::string GameFile::GetNetPlayName(const Core::TitleDatabase& title_database) const
|
||||||
|
|
|
@ -954,8 +954,7 @@ void VertexManagerBase::OnDraw()
|
||||||
|
|
||||||
// Check if this draw is scheduled to kick a command buffer.
|
// Check if this draw is scheduled to kick a command buffer.
|
||||||
// The draw counters will always be sorted so a binary search is possible here.
|
// The draw counters will always be sorted so a binary search is possible here.
|
||||||
if (std::binary_search(m_scheduled_command_buffer_kicks.begin(),
|
if (std::ranges::binary_search(m_scheduled_command_buffer_kicks, m_draw_counter))
|
||||||
m_scheduled_command_buffer_kicks.end(), m_draw_counter))
|
|
||||||
{
|
{
|
||||||
// Kick a command buffer on the background thread.
|
// Kick a command buffer on the background thread.
|
||||||
g_gfx->Flush();
|
g_gfx->Flush();
|
||||||
|
|
Loading…
Reference in New Issue