mirror of
https://github.com/junegunn/fzf
synced 2026-06-09 10:03:17 +00:00
Replace nested max calls with single max
This commit is contained in:
committed by
Junegunn Choi
parent
6eb4b41e34
commit
d6ded42026
+3
-3
@@ -589,7 +589,7 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util.
|
|||||||
if b >= bonusBoundary && b > fb {
|
if b >= bonusBoundary && b > fb {
|
||||||
consecutive = 1
|
consecutive = 1
|
||||||
} else {
|
} else {
|
||||||
b = max(b, max(bonusConsecutive, fb))
|
b = max(b, bonusConsecutive, fb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s1+b < s2 {
|
if s1+b < s2 {
|
||||||
@@ -602,7 +602,7 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util.
|
|||||||
Csub[off] = consecutive
|
Csub[off] = consecutive
|
||||||
|
|
||||||
inGap = s1 < s2
|
inGap = s1 < s2
|
||||||
score := max(max(s1, s2), 0)
|
score := max(s1, s2, 0)
|
||||||
if pidx == M-1 && (forward && score > maxScore || !forward && score >= maxScore) {
|
if pidx == M-1 && (forward && score > maxScore || !forward && score >= maxScore) {
|
||||||
maxScore, maxScorePos = score, col
|
maxScore, maxScorePos = score, col
|
||||||
}
|
}
|
||||||
@@ -686,7 +686,7 @@ func calculateScore(caseSensitive bool, normalize bool, text *util.Chars, patter
|
|||||||
if bonus >= bonusBoundary && bonus > firstBonus {
|
if bonus >= bonusBoundary && bonus > firstBonus {
|
||||||
firstBonus = bonus
|
firstBonus = bonus
|
||||||
}
|
}
|
||||||
bonus = max(max(bonus, firstBonus), bonusConsecutive)
|
bonus = max(bonus, firstBonus, bonusConsecutive)
|
||||||
}
|
}
|
||||||
if pidx == 0 {
|
if pidx == 0 {
|
||||||
score += int(bonus * bonusFirstCharMultiplier)
|
score += int(bonus * bonusFirstCharMultiplier)
|
||||||
|
|||||||
Reference in New Issue
Block a user