Minor refactoring

This commit is contained in:
Junegunn Choi 2015-01-09 02:35:20 +09:00
parent f401c42f9c
commit d303c5b3eb
2 changed files with 2 additions and 3 deletions

View File

@ -90,7 +90,7 @@ func ExactMatchNaive(caseSensitive bool, input *string, pattern []rune) (int, in
runes := []rune(*input)
numRunes := len(runes)
plen := len(pattern)
if len(runes) < plen {
if numRunes < plen {
return -1, -1
}

View File

@ -118,14 +118,13 @@ func awkTokenizer(input *string) ([]string, int) {
}
func Tokenize(str *string, delimiter *regexp.Regexp) []Token {
prefixLength := 0
if delimiter == nil {
// AWK-style (\S+\s*)
tokens, prefixLength := awkTokenizer(str)
return withPrefixLengths(tokens, prefixLength)
} else {
tokens := delimiter.FindAllString(*str, -1)
return withPrefixLengths(tokens, prefixLength)
return withPrefixLengths(tokens, 0)
}
}