From d4f3d5a16423fbf039644f04516c052d1654326c Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 15 Jul 2017 12:28:29 +0900 Subject: Remove pointer indirection by changing Chunk definition --- src/core.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core.go') 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 } -- cgit v1.2.3