mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 19:39:07 +00:00
[perf] evaluateBonus can start from sidx - 1
This commit is contained in:
parent
d9c8a9a880
commit
41e916a511
@ -55,7 +55,7 @@ func evaluateBonus(caseSensitive bool, text util.Chars, pattern []rune, sidx int
|
||||
lenPattern := len(pattern)
|
||||
consecutive := false
|
||||
prevClass := charNonWord
|
||||
for index := 0; index < eidx; index++ {
|
||||
for index := util.Max(0, sidx-1); index < eidx; index++ {
|
||||
char := text.Get(index)
|
||||
var class charClass
|
||||
if unicode.IsLower(char) {
|
||||
|
@ -10,14 +10,11 @@ import (
|
||||
)
|
||||
|
||||
// Max returns the largest integer
|
||||
func Max(first int, items ...int) int {
|
||||
max := first
|
||||
for _, item := range items {
|
||||
if item > max {
|
||||
max = item
|
||||
func Max(first int, second int) int {
|
||||
if first >= second {
|
||||
return first
|
||||
}
|
||||
}
|
||||
return max
|
||||
return second
|
||||
}
|
||||
|
||||
// Min returns the smallest integer
|
||||
|
@ -3,7 +3,7 @@ package util
|
||||
import "testing"
|
||||
|
||||
func TestMax(t *testing.T) {
|
||||
if Max(-2, 5, 1, 4, 3) != 5 {
|
||||
if Max(-2, 5) != 5 {
|
||||
t.Error("Invalid result")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user