Skip to content

Commit

Permalink
fix iOS crash: strict weak ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Oct 5, 2024
1 parent 9eca643 commit 556be7f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/hallelujah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,13 @@ void HallelujahState::keyEvent(KeyEvent &event) {
words.begin(), words.begin() + n, words.end(),
[this, &normalized](const std::string &a,
const std::string &b) {
if (a == normalized) {
return true;
}
if (b == normalized) {
return false;
}
auto na = a == normalized ? 1 : 0;
auto nb = b == normalized ? 1 : 0;
auto ia = words_->find(a);
auto fa = ia == words_->end() ? 0 : ia->second.frequency_;
auto ib = words_->find(b);
auto fb = ib == words_->end() ? 0 : ib->second.frequency_;
return fa > fb;
return std::tie(na, fa, a) > std::tie(nb, fb, b);
});
words.resize(n);
} else {
Expand Down

0 comments on commit 556be7f

Please sign in to comment.