diff options
-rw-r--r-- | src/algo/algo.go | 2 | ||||
-rw-r--r-- | src/util/util.go | 11 | ||||
-rw-r--r-- | src/util/util_test.go | 2 |
3 files changed, 6 insertions, 9 deletions
diff --git a/src/algo/algo.go b/src/algo/algo.go index 9bf476fd..63469c90 100644 --- a/src/algo/algo.go +++ b/src/algo/algo.go @@ -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) { diff --git a/src/util/util.go b/src/util/util.go index a95340e7..113fee91 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -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 diff --git a/src/util/util_test.go b/src/util/util_test.go index 06cfd4f2..d6a03d9d 100644 --- a/src/util/util_test.go +++ b/src/util/util_test.go @@ -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") } } |