Optimize list

This commit is contained in:
s.kamardin 2016-01-19 20:52:25 +03:00
parent 41a0d4481c
commit b3c56781e2
1 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/gobwas/glob/match" "github.com/gobwas/glob/match"
"reflect" "reflect"
"unicode/utf8"
) )
func optimize(matcher match.Matcher) match.Matcher { func optimize(matcher match.Matcher) match.Matcher {
@ -21,6 +22,13 @@ func optimize(matcher match.Matcher) match.Matcher {
return m return m
case match.List:
if m.Not == false && utf8.RuneCountInString(m.List) == 1 {
return match.NewText(m.List)
}
return m
case match.BTree: case match.BTree:
m.Left = optimize(m.Left) m.Left = optimize(m.Left)
m.Right = optimize(m.Right) m.Right = optimize(m.Right)