Skip to content

Commit

Permalink
fix(algo, dict): add an extra set of parenthesis to std::min ...
Browse files Browse the repository at this point in the history
... to prevent min macro invocation on Windows.
  • Loading branch information
WhiredPlanck authored and lotem committed Nov 12, 2022
1 parent 24e1612 commit f66d330
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/rime/algo/syllabifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int Syllabifier::BuildSyllableGraph(const string &input,
if (it == spellings.end()) {
spellings.insert({syllable_id, props});
} else {
it->second.type = std::min(it->second.type, props.type);
it->second.type = (std::min)(it->second.type, props.type);
}
// let end_vertex_type be the best (smaller) type of spelling
// that ends at the vertex
Expand Down
8 changes: 4 additions & 4 deletions src/rime/dict/corrector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Distance EditDistanceCorrector::LevenshteinDistance(const std::string &s1, const
last_diagonal + SubstCost(s1[y - 1], s2[x - 1])
};

column[y] = std::min(possibilities);
column[y] = (std::min)(possibilities);
last_diagonal = old_diagonal;
}
}
Expand All @@ -199,15 +199,15 @@ Distance EditDistanceCorrector::RestrictedDistance(const std::string& s1,
for(size_t i = 1; i <= len1; ++i) {
auto min_d = threshold + 1;
for(size_t j = 1; j <= len2; ++j) {
d[index(i, j)] = std::min({
d[index(i, j)] = (std::min)({
d[index(i - 1, j)] + 2,
d[index(i, j - 1)] + 2,
d[index(i - 1, j - 1)] + SubstCost(s1[i - 1], s2[j - 1])
});
if (i > 1 && j > 1 && s1[i - 2] == s2[j - 1] && s1[i - 1] == s2[j - 2]) {
d[index(i, j)] = std::min(d[index(i, j)], d[index(i - 2, j - 2)] + 2);
d[index(i, j)] = (std::min)(d[index(i, j)], d[index(i - 2, j - 2)] + 2);
}
min_d = std::min(min_d, d[index(i, j)]);
min_d = (std::min)(min_d, d[index(i, j)]);
}
// early termination: do not continue if too far
if (min_d > threshold)
Expand Down

0 comments on commit f66d330

Please sign in to comment.