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