From c65eb46cf38c448fcc75d5115f3578c1f7762382 Mon Sep 17 00:00:00 2001 From: "s.kamardin" Date: Thu, 14 Jan 2016 18:38:16 +0300 Subject: [PATCH] Cleanup --- .gitignore | 3 +++ match/any.go | 4 ---- match/any_of.go | 4 ---- match/btree.go | 4 ---- match/contains.go | 4 ---- match/every_of.go | 4 ---- match/list.go | 4 ---- match/match.go | 22 ---------------------- match/max.go | 8 -------- match/min.go | 8 -------- match/prefix.go | 12 ------------ match/prefix_suffix.go | 12 ------------ match/range.go | 4 ---- match/raw.go | 4 ---- match/row.go | 4 ---- match/single.go | 4 ---- match/suffix.go | 12 ------------ match/super.go | 4 ---- 18 files changed, 3 insertions(+), 118 deletions(-) diff --git a/.gitignore b/.gitignore index 4144260..e622226 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ glob.iml .idea +*.cpu +*.mem +*.test \ No newline at end of file diff --git a/match/any.go b/match/any.go index ba13645..a1885c5 100644 --- a/match/any.go +++ b/match/any.go @@ -39,10 +39,6 @@ func (self Any) Len() int { return lenNo } -func (self Any) Kind() Kind { - return KindAny -} - func (self Any) String() string { return fmt.Sprintf("", self.Separators) } diff --git a/match/any_of.go b/match/any_of.go index 46a6f36..3d14edc 100644 --- a/match/any_of.go +++ b/match/any_of.go @@ -79,10 +79,6 @@ func (self AnyOf) Len() (l int) { return } -func (self AnyOf) Kind() Kind { - return KindAnyOf -} - func (self AnyOf) String() string { return fmt.Sprintf("", self.Matchers) } diff --git a/match/btree.go b/match/btree.go index d9ce037..4168539 100644 --- a/match/btree.go +++ b/match/btree.go @@ -42,10 +42,6 @@ func NewBTree(Value, Left, Right Matcher) (tree BTree) { return tree } -func (self BTree) Kind() Kind { - return KindBTree -} - func (self BTree) Len() int { return self.Length } diff --git a/match/contains.go b/match/contains.go index a9ff543..23f51b6 100644 --- a/match/contains.go +++ b/match/contains.go @@ -56,10 +56,6 @@ func (self Contains) Len() int { return lenNo } -func (self Contains) Kind() Kind { - return KindContains -} - func (self Contains) String() string { var not string if self.Not { diff --git a/match/every_of.go b/match/every_of.go index 4174ce3..5df2fbc 100644 --- a/match/every_of.go +++ b/match/every_of.go @@ -74,10 +74,6 @@ func (self EveryOf) Match(s string) bool { return true } -func (self EveryOf) Kind() Kind { - return KindEveryOf -} - func (self EveryOf) String() string { return fmt.Sprintf("", self.Matchers) } diff --git a/match/list.go b/match/list.go index 06068a5..5739301 100644 --- a/match/list.go +++ b/match/list.go @@ -11,10 +11,6 @@ type List struct { Not bool } -func (self List) Kind() Kind { - return KindList -} - func (self List) Match(s string) bool { inList := strings.Index(self.List, s) != -1 return inList == !self.Not diff --git a/match/match.go b/match/match.go index 39989b8..1b18118 100644 --- a/match/match.go +++ b/match/match.go @@ -5,28 +5,6 @@ import ( "strings" ) -type Kind int - -// todo use String for Kind, and self.Kind() in every matcher.String() -const ( - KindRaw Kind = iota - KindEveryOf - KindAnyOf - KindAny - KindSuper - KindSingle - KindComposition - KindPrefix - KindSuffix - KindPrefixSuffix - KindRange - KindList - KindMin - KindMax - KindBTree - KindContains -) - const lenOne = 1 const lenNo = -1 diff --git a/match/max.go b/match/max.go index cc7244a..614154b 100644 --- a/match/max.go +++ b/match/max.go @@ -44,14 +44,6 @@ func (self Max) Len() int { return lenNo } -func (self Max) Search(s string) (int, int, bool) { - return 0, 0, false -} - -func (self Max) Kind() Kind { - return KindMax -} - func (self Max) String() string { return fmt.Sprintf("", self.Limit) } diff --git a/match/min.go b/match/min.go index 1df3072..cb330b4 100644 --- a/match/min.go +++ b/match/min.go @@ -44,14 +44,6 @@ func (self Min) Len() int { return lenNo } -func (self Min) Search(s string) (int, int, bool) { - return 0, 0, false -} - -func (self Min) Kind() Kind { - return KindMin -} - func (self Min) String() string { return fmt.Sprintf("", self.Limit) } diff --git a/match/prefix.go b/match/prefix.go index 097e316..bf73ae2 100644 --- a/match/prefix.go +++ b/match/prefix.go @@ -10,10 +10,6 @@ type Prefix struct { Prefix string } -func (self Prefix) Kind() Kind { - return KindPrefix -} - func (self Prefix) Index(s string) (int, []int) { idx := strings.Index(s, self.Prefix) if idx == -1 { @@ -41,14 +37,6 @@ func (self Prefix) Len() int { return lenNo } -func (self Prefix) Search(s string) (i int, l int, ok bool) { - if self.Match(s) { - return 0, len(s), true - } - - return -} - func (self Prefix) Match(s string) bool { return strings.HasPrefix(s, self.Prefix) } diff --git a/match/prefix_suffix.go b/match/prefix_suffix.go index 6d3af9e..df8890b 100644 --- a/match/prefix_suffix.go +++ b/match/prefix_suffix.go @@ -9,10 +9,6 @@ type PrefixSuffix struct { Prefix, Suffix string } -func (self PrefixSuffix) Kind() Kind { - return KindPrefixSuffix -} - func (self PrefixSuffix) Index(s string) (int, []int) { prefixIdx := strings.Index(s, self.Prefix) if prefixIdx == -1 { @@ -47,14 +43,6 @@ func (self PrefixSuffix) Len() int { return lenNo } -func (self PrefixSuffix) Search(s string) (i int, l int, ok bool) { - if self.Match(s) { - return 0, len(s), true - } - - return -} - func (self PrefixSuffix) Match(s string) bool { return strings.HasPrefix(s, self.Prefix) && strings.HasSuffix(s, self.Suffix) } diff --git a/match/range.go b/match/range.go index 42453c6..f8b6f5d 100644 --- a/match/range.go +++ b/match/range.go @@ -10,10 +10,6 @@ type Range struct { Not bool } -func (self Range) Kind() Kind { - return KindRange -} - func (self Range) Len() int { return lenOne } diff --git a/match/raw.go b/match/raw.go index 12c86fa..e51ca68 100644 --- a/match/raw.go +++ b/match/raw.go @@ -27,10 +27,6 @@ func (self Raw) Len() int { return self.Length } -func (self Raw) Kind() Kind { - return KindRaw -} - func (self Raw) Index(s string) (index int, segments []int) { index = strings.Index(s, self.Str) if index == -1 { diff --git a/match/row.go b/match/row.go index 9982ed4..9e4f895 100644 --- a/match/row.go +++ b/match/row.go @@ -57,10 +57,6 @@ func (self Row) Index(s string) (int, []int) { return -1, nil } -func (self Row) Kind() Kind { - return KindMin -} - func (self Row) String() string { return fmt.Sprintf("", self.Length, self.Matchers) } diff --git a/match/single.go b/match/single.go index b35e80b..f70d12e 100644 --- a/match/single.go +++ b/match/single.go @@ -29,10 +29,6 @@ func (self Single) Index(s string) (int, []int) { return -1, nil } -func (self Single) Kind() Kind { - return KindSingle -} - func (self Single) String() string { return fmt.Sprintf("", self.Separators) } diff --git a/match/suffix.go b/match/suffix.go index 670724a..d38d71a 100644 --- a/match/suffix.go +++ b/match/suffix.go @@ -9,10 +9,6 @@ type Suffix struct { Suffix string } -func (self Suffix) Kind() Kind { - return KindSuffix -} - func (self Suffix) Index(s string) (int, []int) { idx := strings.Index(s, self.Suffix) if idx == -1 { @@ -26,14 +22,6 @@ func (self Suffix) Len() int { return lenNo } -func (self Suffix) Search(s string) (i int, l int, ok bool) { - if self.Match(s) { - return 0, len(s), true - } - - return -} - func (self Suffix) Match(s string) bool { return strings.HasSuffix(s, self.Suffix) } diff --git a/match/super.go b/match/super.go index a7e0979..19b718f 100644 --- a/match/super.go +++ b/match/super.go @@ -26,10 +26,6 @@ func (self Super) Index(s string) (int, []int) { return 0, segments } -func (self Super) Kind() Kind { - return KindSuper -} - func (self Super) String() string { return fmt.Sprintf("") }