[PATCH] D44720: [clangd] Simplify fuzzy matcher (sequence alignment) by removing some condition checks.
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 29 09:12:07 PDT 2018
MaskRay added inline comments.
================
Comment at: clangd/FuzzyMatch.cpp:96
return None;
return ScoreScale * std::min(PerfectBonus * PatN, std::max<int>(0, Best));
}
----------------
sammccall wrote:
> MaskRay wrote:
> > I also don't understand why it clamps the value to zero here. Negative values are also meaningful to me. Given that perfectBonus is only 3 it is very easy to get a negative value here.
> An important part of the contract of `match()` is that it returns a value in `[0,1]`.
> We rely on this range to combine this with other scoring signals - we multiply this by a quality signal in code completion.
> (Currently the quality signal is just derived from Sema, but the global index will provide the number of uses).
>
> It would be possible to use a different squash function here, but I found max(kFloor,x) worked well for the examples I looked at - anything <= some floor value was "not really a useful match at all", and most of the variance below the floor seemed to be noise to me.
> (Then I tuned the bonuses/penalties so the floor was at zero)
We could try other criteria in the future. I believe the current one can be improved because negative scores may be returned but the scoring shouldn't return 0 for all the cases.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D44720
More information about the cfe-commits
mailing list