diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-07-15 12:28:29 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-07-16 23:34:32 +0900 |
commit | d4f3d5a16423fbf039644f04516c052d1654326c (patch) | |
tree | 2cb3f9519a23e9e9c162d135636d9f99373deadc /src/core.go | |
parent | 7b5ccc45bc76f289fe2c48cf91e895b9ca99b1e2 (diff) |
Remove pointer indirection by changing Chunk definition
Diffstat (limited to 'src/core.go')
-rw-r--r-- | src/core.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core.go b/src/core.go index a528dbb6..7e16dc35 100644 --- a/src/core.go +++ b/src/core.go @@ -91,27 +91,27 @@ func Run(opts *Options, revision string) { var chunkList *ChunkList header := make([]string, 0, opts.HeaderLines) if len(opts.WithNth) == 0 { - chunkList = NewChunkList(func(data []byte, index int) *Item { + chunkList = NewChunkList(func(data []byte, index int) Item { if len(header) < opts.HeaderLines { header = append(header, string(data)) eventBox.Set(EvtHeader, header) - return nil + return nilItem } chars, colors := ansiProcessor(data) - return &Item{ + return Item{ index: int32(index), trimLength: -1, text: chars, colors: colors} }) } else { - chunkList = NewChunkList(func(data []byte, index int) *Item { + chunkList = NewChunkList(func(data []byte, index int) Item { tokens := Tokenize(util.ToChars(data), opts.Delimiter) trans := Transform(tokens, opts.WithNth) if len(header) < opts.HeaderLines { header = append(header, string(joinTokens(trans))) eventBox.Set(EvtHeader, header) - return nil + return nilItem } textRunes := joinTokens(trans) item := Item{ @@ -123,7 +123,7 @@ func Run(opts *Options, revision string) { trimmed, colors := ansiProcessorRunes(textRunes) item.text = trimmed item.colors = colors - return &item + return item }) } @@ -168,8 +168,8 @@ func Run(opts *Options, revision string) { reader := Reader{ func(runes []byte) bool { item := chunkList.trans(runes, 0) - if item != nil { - if result, _, _ := pattern.MatchItem(item, false, slab); result != nil { + if !item.Nil() { + if result, _, _ := pattern.MatchItem(&item, false, slab); result != nil { opts.Printer(item.text.ToString()) found = true } |