mirror of https://github.com/gobwas/glob.git
Optimize list
This commit is contained in:
parent
41a0d4481c
commit
b3c56781e2
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue