forked from mirror/glob
tune
This commit is contained in:
parent
462ce6e3ac
commit
0c30789d3a
|
@ -18,7 +18,6 @@ func (self Any) Index(s string, segments []int) (int, []int) {
|
|||
switch found {
|
||||
case -1:
|
||||
case 0:
|
||||
segments = append(segments)
|
||||
return 0, segments
|
||||
default:
|
||||
s = s[:found]
|
||||
|
@ -27,7 +26,6 @@ func (self Any) Index(s string, segments []int) (int, []int) {
|
|||
for i := range s {
|
||||
segments = append(segments, i)
|
||||
}
|
||||
|
||||
segments = append(segments, len(s))
|
||||
|
||||
return 0, segments
|
||||
|
|
|
@ -27,10 +27,10 @@ func (self AnyOf) Index(s string, segments []int) (int, []int) {
|
|||
index := -1
|
||||
|
||||
// create reusable segments
|
||||
in := make([]int, 0, len(s))
|
||||
seg := make([]int, 0, len(s))
|
||||
|
||||
for _, m := range self.Matchers {
|
||||
idx, seg := m.Index(s, in[:0])
|
||||
idx, seg := m.Index(s, seg[:0])
|
||||
if idx == -1 {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -79,11 +79,11 @@ func (self BTree) Match(s string) bool {
|
|||
|
||||
// reusable segments list
|
||||
// inputLen is the maximum size of output segments values
|
||||
in := make([]int, 0, inputLen)
|
||||
segments := make([]int, 0, inputLen)
|
||||
|
||||
for offset < limit {
|
||||
// search for matching part in substring
|
||||
index, segments := self.Value.Index(s[offset:limit], in[:0])
|
||||
index, segments := self.Value.Index(s[offset:limit], segments[:0])
|
||||
if index == -1 {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -31,13 +31,13 @@ func (self EveryOf) Index(s string, out []int) (int, []int) {
|
|||
|
||||
// make `in` with cap as len(s),
|
||||
// cause it is the maximum size of output segments values
|
||||
in := make([]int, 0, len(s))
|
||||
seg := make([]int, 0, len(s))
|
||||
next := make([]int, 0, len(s))
|
||||
current := make([]int, 0, len(s))
|
||||
|
||||
sub := s
|
||||
for i, m := range self.Matchers {
|
||||
idx, seg := m.Index(sub, in[:0])
|
||||
idx, seg := m.Index(sub, seg[:0])
|
||||
if idx == -1 {
|
||||
return -1, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue