Internals: Mark some functions of VSpellCheck 'const'. No functional change is intended. (#2817)

This commit is contained in:
Yutetsu TAKATSUKASA 2021-03-04 22:08:44 +09:00 committed by GitHub
parent ed2f8dc097
commit 97b869e5d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -460,7 +460,7 @@ VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t ca
return (max_length + 2) / 3; return (max_length + 2) / 3;
} }
string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distancer) { string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distancer) const {
string bestCandidate; string bestCandidate;
size_t gLen = goal.length(); size_t gLen = goal.length();
distancer = LENGTH_LIMIT * 10; distancer = LENGTH_LIMIT * 10;

View File

@ -208,12 +208,12 @@ public:
if (m_candidates.size() < NUM_CANDIDATE_LIMIT) m_candidates.push_back(s); if (m_candidates.size() < NUM_CANDIDATE_LIMIT) m_candidates.push_back(s);
} }
// Return candidate is closest to provided string, or "" for none // Return candidate is closest to provided string, or "" for none
string bestCandidate(const string& goal) { string bestCandidate(const string& goal) const {
EditDistance dist; EditDistance dist;
return bestCandidateInfo(goal, dist /*ref*/); return bestCandidateInfo(goal, dist /*ref*/);
} }
// Return friendly message // Return friendly message
string bestCandidateMsg(const string& goal) { string bestCandidateMsg(const string& goal) const {
string candidate = bestCandidate(goal); string candidate = bestCandidate(goal);
if (candidate.empty()) { if (candidate.empty()) {
return ""; return "";
@ -226,7 +226,7 @@ public:
private: private:
static EditDistance editDistance(const string& s, const string& t); static EditDistance editDistance(const string& s, const string& t);
static EditDistance cutoffDistance(size_t goal_len, size_t candidate_len); static EditDistance cutoffDistance(size_t goal_len, size_t candidate_len);
string bestCandidateInfo(const string& goal, EditDistance& distancer); string bestCandidateInfo(const string& goal, EditDistance& distancer) const;
static void selfTestDistanceOne(const string& a, const string& b, EditDistance expected); static void selfTestDistanceOne(const string& a, const string& b, EditDistance expected);
static void selfTestSuggestOne(bool matches, const string& c, const string& goal, static void selfTestSuggestOne(bool matches, const string& c, const string& goal,
EditDistance dist); EditDistance dist);