CheatSearch: Use index range for ClonePartial

Specify the begin and end indices instead of filling a vector with all
the indices which are continuous anyway.
This commit is contained in:
Dentomologist 2023-10-26 13:06:16 -07:00
commit fa7c969e15
3 changed files with 15 additions and 30 deletions

View file

@ -614,17 +614,15 @@ std::unique_ptr<Cheats::CheatSearchSessionBase> Cheats::CheatSearchSession<T>::C
template <typename T>
std::unique_ptr<Cheats::CheatSearchSessionBase>
Cheats::CheatSearchSession<T>::ClonePartial(const std::vector<size_t>& result_indices) const
Cheats::CheatSearchSession<T>::ClonePartial(const size_t begin_index, const size_t end_index) const
{
const auto& results = m_search_results;
std::vector<SearchResult<T>> partial_results;
partial_results.reserve(result_indices.size());
for (size_t idx : result_indices)
partial_results.push_back(results[idx]);
if (begin_index == 0 && end_index >= m_search_results.size())
return Clone();
auto c =
std::make_unique<Cheats::CheatSearchSession<T>>(m_memory_ranges, m_address_space, m_aligned);
c->m_search_results = std::move(partial_results);
c->m_search_results.assign(m_search_results.begin() + begin_index,
m_search_results.begin() + end_index);
c->m_compare_type = this->m_compare_type;
c->m_filter_type = this->m_filter_type;
c->m_value = this->m_value;