Merge pull request #6455 from JosJuice/qt-trans-iterator

DolphinQt2: Fix issues with MoIterator
This commit is contained in:
Pierre Bourdon 2018-03-17 23:19:26 +01:00 committed by GitHub
commit 7465906a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -53,7 +53,10 @@ public:
// boost::iterator_facade library, which nicely separates out application logic from // boost::iterator_facade library, which nicely separates out application logic from
// iterator-concept logic. // iterator-concept logic.
void advance(difference_type n) { m_index += n; } void advance(difference_type n) { m_index += n; }
difference_type distance_to(const MoIterator& other) const { return other.m_index - m_index; } difference_type distance_to(const MoIterator& other) const
{
return static_cast<difference_type>(other.m_index) - m_index;
}
reference dereference() const reference dereference() const
{ {
u32 offset = ReadU32(&m_data[m_table_offset + m_index * 8 + 4]); u32 offset = ReadU32(&m_data[m_table_offset + m_index * 8 + 4]);
@ -177,7 +180,7 @@ public:
auto iter = std::lower_bound(begin, end, original_string, auto iter = std::lower_bound(begin, end, original_string,
[](const char* a, const char* b) { return strcmp(a, b) < 0; }); [](const char* a, const char* b) { return strcmp(a, b) < 0; });
if (strcmp(*iter, original_string) != 0) if (iter == end || strcmp(*iter, original_string) != 0)
return original_string; return original_string;
u32 offset = ReadU32(&m_data[m_offset_translation_table + std::distance(begin, iter) * 8 + 4]); u32 offset = ReadU32(&m_data[m_offset_translation_table + std::distance(begin, iter) * 8 + 4]);