diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2017-07-16 23:31:19 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-07-16 23:34:32 +0900 |
| commit | 9e85cba0d06025983a1a747bfc06c9955388d9c0 (patch) | |
| tree | 8fe8dc1fd62ad3ecfbfd02e440fac6cfedcd313c /src/item.go | |
| parent | 4b59ced08f1d417530a25af8fe13aa5d40579220 (diff) | |
| download | fzf-9e85cba0d06025983a1a747bfc06c9955388d9c0.tar.gz | |
Reduce memory footprint of Item struct
Diffstat (limited to 'src/item.go')
| -rw-r--r-- | src/item.go | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/item.go b/src/item.go index 955c31d8..b3879cb8 100644 --- a/src/item.go +++ b/src/item.go @@ -4,33 +4,27 @@ import ( "github.com/junegunn/fzf/src/util" ) -// Item represents each input line +// Item represents each input line. 56 bytes. type Item struct { - index int32 - trimLength int32 - text util.Chars - origText *[]byte - colors *[]ansiOffset - transformed []Token + text util.Chars // 32 = 24 + 1 + 1 + 2 + 4 + transformed *[]Token // 8 + origText *[]byte // 8 + colors *[]ansiOffset // 8 } // Index returns ordinal index of the Item func (item *Item) Index() int32 { - return item.index + return item.text.Index } -var nilItem = Item{index: -1} +var nilItem = Item{text: util.Chars{Index: -1}} func (item *Item) Nil() bool { - return item.index < 0 + return item.Index() < 0 } -func (item *Item) TrimLength() int32 { - if item.trimLength >= 0 { - return item.trimLength - } - item.trimLength = int32(item.text.TrimLength()) - return item.trimLength +func (item *Item) TrimLength() uint16 { + return item.text.TrimLength() } // Colors returns ansiOffsets of the Item |
