aboutsummaryrefslogtreecommitdiff
path: root/gcc/spellcheck.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/spellcheck.h')
-rw-r--r--gcc/spellcheck.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/spellcheck.h b/gcc/spellcheck.h
index 7379399..035f4ac 100644
--- a/gcc/spellcheck.h
+++ b/gcc/spellcheck.h
@@ -69,11 +69,12 @@ class best_match
/* Constructor. */
- best_match (goal_t goal)
+ best_match (GOAL_TYPE goal,
+ edit_distance_t best_distance_so_far = MAX_EDIT_DISTANCE)
: m_goal (goal_traits::get_string (goal)),
m_goal_len (goal_traits::get_length (goal)),
m_best_candidate (NULL),
- m_best_distance (MAX_EDIT_DISTANCE)
+ m_best_distance (best_distance_so_far)
{}
/* Compare the edit distance between CANDIDATE and m_goal,
@@ -118,6 +119,20 @@ class best_match
}
}
+ /* Assuming that BEST_CANDIDATE is known to be better than
+ m_best_candidate, update (without recomputing the edit distance to
+ the goal). */
+
+ void set_best_so_far (CANDIDATE_TYPE best_candidate,
+ edit_distance_t best_distance,
+ size_t best_candidate_len)
+ {
+ gcc_assert (best_distance < m_best_distance);
+ m_best_candidate = best_candidate;
+ m_best_distance = best_distance;
+ m_best_candidate_len = best_candidate_len;
+ }
+
/* Get the best candidate so far, but applying a filter to ensure
that we return NULL if none of the candidates are close to the goal,
to avoid offering nonsensical suggestions to the user. */
@@ -135,6 +150,9 @@ class best_match
return m_best_candidate;
}
+ edit_distance_t get_best_distance () const { return m_best_distance; }
+ size_t get_best_candidate_length () const { return m_best_candidate_len; }
+
private:
const char *m_goal;
size_t m_goal_len;