Skip to content

Commit 56dfd49

Browse files
committed
Clang tidy fix in pinyin data
1 parent 780027c commit 56dfd49

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/libime/pinyin/pinyindata.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
*/
66

77
#include "pinyindata.h"
8-
#include "libime/pinyin/pinyinencoder.h"
8+
#include "pinyinencoder.h"
99
#include <boost/algorithm/string/predicate.hpp>
1010
#include <fcitx-utils/stringutils.h>
11-
#include <unordered_map>
12-
#include <unordered_set>
13-
#include <utility>
1411

1512
namespace libime {
1613

@@ -990,10 +987,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
990987
} else if (boost::algorithm::ends_with(result, "ua")) {
991988
result[result.size() - 2] = 'a';
992989
result[result.size() - 1] = 'u';
993-
} else if (boost::algorithm::ends_with(result, "uai")) {
994-
result[result.size() - 3] = 'a';
995-
result[result.size() - 2] = 'u';
996-
} else if (boost::algorithm::ends_with(result, "uan")) {
990+
} else if (boost::algorithm::ends_with(result, "uai") ||
991+
boost::algorithm::ends_with(result, "uan")) {
997992
result[result.size() - 3] = 'a';
998993
result[result.size() - 2] = 'u';
999994
} else if (boost::algorithm::ends_with(result, "van")) {
@@ -1027,8 +1022,8 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
10271022
if (entry.flags().test(PinyinFuzzyFlag::AdvancedTypo)) {
10281023
break;
10291024
}
1030-
for (const auto two : {"ai", "ia", "ei", "ie", "ao", "uo", "ou",
1031-
"iu", "an", "en", "in"}) {
1025+
for (const auto *const two : {"ai", "ia", "ei", "ie", "ao", "uo",
1026+
"ou", "iu", "an", "en", "in"}) {
10321027
if (boost::algorithm::ends_with(result, two)) {
10331028
std::swap(result[result.size() - 2],
10341029
result[result.size() - 1]);
@@ -1038,7 +1033,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
10381033
if (entry.flags().test(PinyinFuzzyFlag::AdvancedTypo)) {
10391034
break;
10401035
}
1041-
for (const auto three :
1036+
for (const auto *const three :
10421037
{"ang", "eng", "ing", "ong", "iao", "ian"}) {
10431038
if (boost::algorithm::ends_with(result, three)) {
10441039
std::swap(result[result.size() - 3],
@@ -1049,7 +1044,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
10491044
if (entry.flags().test(PinyinFuzzyFlag::AdvancedTypo)) {
10501045
break;
10511046
}
1052-
for (const auto four : {"iang", "iong"}) {
1047+
for (const auto *const four : {"iang", "iong"}) {
10531048
if (boost::algorithm::ends_with(result, four)) {
10541049
std::swap(result[result.size() - 4],
10551050
result[result.size() - 3]);
@@ -1208,7 +1203,7 @@ std::optional<PinyinEntry> applyFuzzy(const PinyinEntry &entry,
12081203

12091204
void applyFuzzy(PinyinMap &map, PinyinFuzzyFlag fz, int pass = 0) {
12101205
std::vector<PinyinEntry> newEntries;
1211-
for (auto &entry : map) {
1206+
for (const auto &entry : map) {
12121207
if (auto newEntry = applyFuzzy(entry, fz, pass)) {
12131208
newEntries.push_back(*newEntry);
12141209
}

src/libime/pinyin/pinyindata.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <boost/multi_index_container.hpp>
1313
#include <libime/pinyin/pinyinencoder.h>
1414
#include <string>
15-
#include <unordered_set>
1615
#include <utility>
1716
#include <vector>
1817

0 commit comments

Comments
 (0)