Skip to content

Commit 716f4a3

Browse files
committed
replace stringutils::startsWith and endsWith
1 parent aa3ed00 commit 716f4a3

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/libime/pinyin/pinyinprediction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ PinyinPrediction::predict(const State &state,
104104
[this, &sentence, &prevState, &cmp, &intermedidateResult, &dup,
105105
maxSize](std::string_view, std::string_view hz, float cost) {
106106
if (sentence.back().size() < hz.size() &&
107-
fcitx::stringutils::startsWith(hz, sentence.back())) {
107+
hz.starts_with(sentence.back())) {
108108

109109
std::string newWord(hz.substr(sentence.back().size()));
110110
if (dup.contains(newWord)) {

src/libime/table/tablebaseddictionary.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ inline std::string generateTableEntry(uint32_t pinyinKey, std::string_view key,
101101
}
102102

103103
void maybeUnescapeValue(std::string &value) {
104-
if (value.size() >= 2 && fcitx::stringutils::startsWith(value, '"') &&
105-
fcitx::stringutils::endsWith(value, '"')) {
104+
if (value.size() >= 2 && value.starts_with('"') && value.ends_with('"')) {
106105
if (auto unescape = fcitx::stringutils::unescapeForValue(value)) {
107106
value = unescape.value();
108107
}
@@ -112,8 +111,7 @@ void maybeUnescapeValue(std::string &value) {
112111
std::string maybeEscapeValue(std::string_view value) {
113112
auto escaped = fcitx::stringutils::escapeForValue(value);
114113
if (escaped.size() != value.size()) {
115-
if (fcitx::stringutils::startsWith(escaped, "\"") &&
116-
fcitx::stringutils::endsWith(escaped, "\"")) {
114+
if (escaped.starts_with("\"") && escaped.ends_with("\"")) {
117115
return escaped;
118116
}
119117
return fcitx::stringutils::concat("\"", escaped, "\"");
@@ -673,7 +671,7 @@ void TableBasedDictionary::loadText(std::istream &in) {
673671

674672
switch (phase) {
675673
case BuildPhase::PhaseConfig: {
676-
if (fcitx::stringutils::startsWith(line, "#")) {
674+
if (line.starts_with("#")) {
677675
continue;
678676
}
679677

@@ -716,7 +714,7 @@ void TableBasedDictionary::loadText(std::istream &in) {
716714
break;
717715
}
718716
case BuildPhase::PhaseRule: {
719-
if (fcitx::stringutils::startsWith(line, "#")) {
717+
if (line.starts_with("#")) {
720718
continue;
721719
}
722720
if (consumeOptionPrefix(line, STR_DATA)) {

tools/libime_migrate_fcitx4_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ std::optional<std::string> replaceSuffix(const std::string &input,
148148
const std::string &suffix,
149149
std::string_view newSuffix) {
150150
auto name = fs::baseName(input);
151-
if (!stringutils::endsWith(name, suffix)) {
151+
if (!name.ends_with(suffix)) {
152152
return {};
153153
}
154154
// Strip .mb

0 commit comments

Comments
 (0)