diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-08-20 01:46:54 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-08-20 01:53:32 +0900 |
commit | 827a83efbc178390ddd8aaa36d26bce593d0d58f (patch) | |
tree | f8f7533acf360e3e143892249f9e1613375638a3 /src/pattern.go | |
parent | 3e888493866d42845f11c4d57fc8f093a6e28644 (diff) |
Remove Offset slice from Result struct
Diffstat (limited to 'src/pattern.go')
-rw-r--r-- | src/pattern.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pattern.go b/src/pattern.go index 4c35a127..ef148267 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -273,13 +273,13 @@ func (p *Pattern) matchChunk(chunk *Chunk, space []*Result) []*Result { if space == nil { for _, item := range *chunk { - if match := p.MatchItem(item); match != nil { + if match, _ := p.MatchItem(item); match != nil { matches = append(matches, match) } } } else { for _, result := range space { - if match := p.MatchItem(result.item); match != nil { + if match, _ := p.MatchItem(result.item); match != nil { matches = append(matches, match) } } @@ -288,18 +288,19 @@ func (p *Pattern) matchChunk(chunk *Chunk, space []*Result) []*Result { } // MatchItem returns true if the Item is a match -func (p *Pattern) MatchItem(item *Item) *Result { +func (p *Pattern) MatchItem(item *Item) (*Result, []Offset) { if p.extended { if offsets, bonus, trimLen := p.extendedMatch(item); len(offsets) == len(p.termSets) { - return buildResult(item, offsets, bonus, trimLen) + return buildResult(item, offsets, bonus, trimLen), offsets } - return nil + return nil, nil } offset, bonus, trimLen := p.basicMatch(item) if sidx := offset[0]; sidx >= 0 { - return buildResult(item, []Offset{offset}, bonus, trimLen) + offsets := []Offset{offset} + return buildResult(item, offsets, bonus, trimLen), offsets } - return nil + return nil, nil } func (p *Pattern) basicMatch(item *Item) (Offset, int, int) { |