From 9e85cba0d06025983a1a747bfc06c9955388d9c0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 16 Jul 2017 23:31:19 +0900 Subject: Reduce memory footprint of Item struct --- src/chunklist_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/chunklist_test.go') diff --git a/src/chunklist_test.go b/src/chunklist_test.go index 983a7ed8..78468e32 100644 --- a/src/chunklist_test.go +++ b/src/chunklist_test.go @@ -12,7 +12,9 @@ func TestChunkList(t *testing.T) { sortCriteria = []criterion{byScore, byLength} cl := NewChunkList(func(s []byte, i int) Item { - return Item{text: util.ToChars(s), index: int32(i * 2)} + chars := util.ToChars(s) + chars.Index = int32(i * 2) + return Item{text: chars} }) // Snapshot @@ -41,8 +43,8 @@ func TestChunkList(t *testing.T) { if len(*chunk1) != 2 { t.Error("Snapshot should contain only two items") } - if (*chunk1)[0].text.ToString() != "hello" || (*chunk1)[0].index != 0 || - (*chunk1)[1].text.ToString() != "world" || (*chunk1)[1].index != 2 { + if (*chunk1)[0].text.ToString() != "hello" || (*chunk1)[0].Index() != 0 || + (*chunk1)[1].text.ToString() != "world" || (*chunk1)[1].Index() != 2 { t.Error("Invalid data") } if chunk1.IsFull() { -- cgit v1.2.3