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 ac94e7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 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
4 changes: 2 additions & 2 deletions test/testhallelujah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ using namespace fcitx;

std::vector<std::pair<std::vector<std::string>, std::vector<std::string>>>
expectedCommit{
{{"a", "4"}, {"at"}},
{{"a", "4"}, {"are"}},
{{"a", "space"}, {"a "}},
{{"a", "Return"}, {"a"}},
{{"a", "Down", "space"}, {"as "}},
{{"a", "Down", "space"}, {"at "}},
{{"a", "Up", "Return"}, {"also"}},
{{"a", "Escape"}, {}},
{{"a", "b", "BackSpace", "Return"}, {"a"}},
Expand Down

0 comments on commit ac94e7d

Please sign in to comment.