[clangd] Avoid divide-by-zero

llvm-svn: 322668
This commit is contained in:
Sam McCall 2018-01-17 15:25:55 +00:00
parent 01bcfd2112
commit 5668cd3e57
1 changed files with 1 additions and 1 deletions

View File

@ -75,7 +75,7 @@ static constexpr int PerfectBonus = 3; // Perfect per-pattern-char score.
FuzzyMatcher::FuzzyMatcher(StringRef Pattern)
: PatN(std::min<int>(MaxPat, Pattern.size())), CaseSensitive(false),
ScoreScale(float{1} / (PerfectBonus * PatN)), WordN(0) {
ScoreScale(PatN ? float{1} / (PerfectBonus * PatN) : 0), WordN(0) {
memcpy(Pat, Pattern.data(), PatN);
for (int I = 0; I < PatN; ++I) {
LowPat[I] = lower(Pat[I]);