From b3c56781e2ebac22a70eed2d679a0ee81e03efb7 Mon Sep 17 00:00:00 2001 From: "s.kamardin" Date: Tue, 19 Jan 2016 20:52:25 +0300 Subject: [PATCH] Optimize list --- compiler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler.go b/compiler.go index 90a0869..0a38c8e 100644 --- a/compiler.go +++ b/compiler.go @@ -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)