summaryrefslogtreecommitdiffstats
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-07-16 23:31:19 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-07-16 23:34:32 +0900
commit9e85cba0d06025983a1a747bfc06c9955388d9c0 (patch)
tree8fe8dc1fd62ad3ecfbfd02e440fac6cfedcd313c /src/core.go
parent4b59ced08f1d417530a25af8fe13aa5d40579220 (diff)
Reduce memory footprint of Item struct
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/core.go b/src/core.go
index 7e16dc35..aa425109 100644
--- a/src/core.go
+++ b/src/core.go
@@ -98,11 +98,8 @@ func Run(opts *Options, revision string) {
return nilItem
}
chars, colors := ansiProcessor(data)
- return Item{
- index: int32(index),
- trimLength: -1,
- text: chars,
- colors: colors}
+ chars.Index = int32(index)
+ return Item{text: chars, colors: colors}
})
} else {
chunkList = NewChunkList(func(data []byte, index int) Item {
@@ -114,16 +111,9 @@ func Run(opts *Options, revision string) {
return nilItem
}
textRunes := joinTokens(trans)
- item := Item{
- index: int32(index),
- trimLength: -1,
- origText: &data,
- colors: nil}
-
trimmed, colors := ansiProcessorRunes(textRunes)
- item.text = trimmed
- item.colors = colors
- return item
+ trimmed.Index = int32(index)
+ return Item{text: trimmed, colors: colors, origText: &data}
})
}