On 06/14/2016 09:15 AM, David Malcolm wrote:
There's a lot of repetition between find_closest_string and
find_closest_identifier, and the next patch adds more, so this
patch moves the logic into a new template class "best_match"
for locating the closest string from a sequence of candidates.

The patch also introduces a pair of early-reject optimizations
that weren't present in the older implementations, reducing the
number of calls to levenshtein_distance.
Introducing class best_match allows for these optimizations to be
in one place (best_match::consider), rather than having to implement
them twice.

Successfully bootstrapped&regrtested in combination with the rest of
the kit on x86_64-pc-linux-gnu
Successful -fself-test of stage1 on powerpc-ibm-aix7.1.3.0 of
just this patch (on top of patches 1 and 2).

OK for trunk if it passes individual bootstrap&regrtest?

gcc/c/ChangeLog:
        * c-typeck.c: Include spellcheck-tree.h rather than spellcheck.h.

gcc/cp/ChangeLog:
        * search.c: Include spellcheck-tree.h rather than spellcheck.h.

gcc/ChangeLog:
        * spellcheck-tree.c: Include spellcheck-tree.h rather than
        spellcheck.h.
        (find_closest_identifier): Reimplement in terms of
        best_match<tree,tree>.
        * spellcheck-tree.h: New file.
        * spellcheck.c (struct edit_distance_traits<const char *>): New
        struct.
        (find_closest_string): Reimplement in terms of
        best_match<const char *, const char *>.
        * spellcheck.h (levenshtein_distance): Move prototype of tree-based
        overload to spellcheck-tree.h.
        (find_closest_identifier): Likewise.
        (struct edit_distance_traits<T>): New template.
        (class best_match): New class.
OK.
jeff

Reply via email to