Fix --with-nth performance; avoid regex if possible

Close #317
This commit is contained in:
Junegunn Choi
2015-08-10 18:34:20 +09:00
parent a7b75c99a5
commit 766427de0c
7 changed files with 117 additions and 35 deletions

View File

@@ -42,7 +42,7 @@ type Pattern struct {
text []rune
terms []term
hasInvTerm bool
delimiter *regexp.Regexp
delimiter Delimiter
nth []Range
procFun map[termType]func(bool, []rune, []rune) (int, int)
}
@@ -71,7 +71,7 @@ func clearChunkCache() {
// BuildPattern builds Pattern object from the given arguments
func BuildPattern(mode Mode, caseMode Case,
nth []Range, delimiter *regexp.Regexp, runes []rune) *Pattern {
nth []Range, delimiter Delimiter, runes []rune) *Pattern {
var asString string
switch mode {