Skip to content
Myr

[perf] evaluateBonus can start from sidx - 1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent d9c8a9a · Browse files · 3 files+6 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+6 added−9 removed

  • other:+6 added−9 removed

3 files+6 added−9 removed

modified:src/algo/algo.go+1 added-1 removed
53 unmodified lines
54 pidx := 055 lenPattern := len(pattern)56 consecutive := false57 prevClass := charNonWord58 for index := 0; index < eidx; index++ {58 for index := util.Max(0, sidx-1); index < eidx; index++ {59 char := text.Get(index)60 var class charClass61 if unicode.IsLower(char) {62 class = charLower
245 unmodified lines
modified:src/util/util_test.go+1 added-1 removed
1 unmodified line
23import "testing"45func TestMax(t *testing.T) {6 if Max(-2, 5, 1, 4, 3) != 5 {6 if Max(-2, 5) != 5 {7 t.Error("Invalid result")8 }9}10
12 unmodified lines
modified:src/util/util.go+4 added-7 removed
8 unmodified lines
9 "time"10)1112// Max returns the largest integer13func Max(first int, items ...int) int {14 max := first15 for _, item := range items {16 if item > max {17 max = item18 }13func Max(first int, second int) int {14 if first >= second {15 return first16 }20 return max17 return second18}1920// Min returns the smallest integer21func Min(first int, second int) int {
69 unmodified lines