Skip to content

Commit

Permalink
Clang tidy fix in pinyin data
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Mar 23, 2024
1 parent 780027c commit 56dfd49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
21 changes: 8 additions & 13 deletions src/libime/pinyin/pinyindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
*/

#include "pinyindata.h"
#include "libime/pinyin/pinyinencoder.h"
#include "pinyinencoder.h"
#include <boost/algorithm/string/predicate.hpp>
#include <fcitx-utils/stringutils.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>

namespace libime {

Expand Down Expand Up @@ -990,10 +987,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
} else if (boost::algorithm::ends_with(result, "ua")) {
result[result.size() - 2] = 'a';
result[result.size() - 1] = 'u';
} else if (boost::algorithm::ends_with(result, "uai")) {
result[result.size() - 3] = 'a';
result[result.size() - 2] = 'u';
} else if (boost::algorithm::ends_with(result, "uan")) {
} else if (boost::algorithm::ends_with(result, "uai") ||
boost::algorithm::ends_with(result, "uan")) {
result[result.size() - 3] = 'a';
result[result.size() - 2] = 'u';
} else if (boost::algorithm::ends_with(result, "van")) {
Expand Down Expand Up @@ -1027,8 +1022,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
if (entry.flags().test(PinyinFuzzyFlag::AdvancedTypo)) {
break;
}
for (const auto two : {"ai", "ia", "ei", "ie", "ao", "uo", "ou",
"iu", "an", "en", "in"}) {
for (const auto *const two : {"ai", "ia", "ei", "ie", "ao", "uo",
"ou", "iu", "an", "en", "in"}) {
if (boost::algorithm::ends_with(result, two)) {
std::swap(result[result.size() - 2],
result[result.size() - 1]);
Expand All @@ -1038,7 +1033,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
if (entry.flags().test(PinyinFuzzyFlag::AdvancedTypo)) {
break;
}
for (const auto three :
for (const auto *const three :
{"ang", "eng", "ing", "ong", "iao", "ian"}) {
if (boost::algorithm::ends_with(result, three)) {
std::swap(result[result.size() - 3],
Expand All @@ -1049,7 +1044,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
if (entry.flags().test(PinyinFuzzyFlag::AdvancedTypo)) {
break;
}
for (const auto four : {"iang", "iong"}) {
for (const auto *const four : {"iang", "iong"}) {
if (boost::algorithm::ends_with(result, four)) {
std::swap(result[result.size() - 4],
result[result.size() - 3]);
Expand Down Expand Up @@ -1208,7 +1203,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,

void applyFuzzy(PinyinMap &map, PinyinFuzzyFlag fz, int pass = 0) {
std::vector<PinyinEntry> newEntries;
for (auto &entry : map) {
for (const auto &entry : map) {
if (auto newEntry = applyFuzzy(entry, fz, pass)) {
newEntries.push_back(*newEntry);
}
Expand Down
1 change: 0 additions & 1 deletion src/libime/pinyin/pinyindata.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <boost/multi_index_container.hpp>
#include <libime/pinyin/pinyinencoder.h>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>

Expand Down

0 comments on commit 56dfd49

Please sign in to comment.