[PATCH] D59300: [clangd] Tune the fuzzy-matching algorithm
Eric Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 15 03:42:58 PDT 2019
ioeric added inline comments.
================
Comment at: clang-tools-extra/clangd/FuzzyMatch.cpp:285
+ if (Pat[P] == Word[W] ||
+ (WordRole[W] == Head && (IsPatSingleCase || PatRole[P] == Head)))
++S;
----------------
ilya-biryukov wrote:
> ioeric wrote:
> > could you explain the intention of this change? Is it relevant to other changes in the patch? The original looks reasonable to me.
> The motivation is keeping a bonus for matching the head of a segment even in case of single-case patterns that lack segmentation signals.
> Previously, `p` from `up` would not get this bonus when matching `unique_[p]tr` even though intuitively it should as we do want to encourage those matches.
so, iiuc, when `IsPatSingleCase` is true, it means that any character in the pattern can potentially be a head? could you add comment for this?
We also had a stricter condition for `Pat[P] == Word[W]`, but now `ut` would get a bonus for `[u]nique_p[t]r`. Is this intended?
================
Comment at: clang-tools-extra/clangd/FuzzyMatch.cpp:273
if (WordRole[W] == Head) // Skipping a segment.
- S += 1;
- if (Last == Match) // Non-consecutive match.
- S += 2; // We'd rather skip a segment than split our match.
- return S;
+ return 1; // We want to keep it lower than the bonus for a consecutive
+ // match.
----------------
nit: move this comment into into own line now that it's taking two?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59300/new/
https://reviews.llvm.org/D59300
More information about the cfe-commits
mailing list