diff options
| author | Shulhan <ms@kilabit.info> | 2023-09-10 23:36:27 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-09-11 02:26:33 +0700 |
| commit | 9d05da3b79182f0fa63c268cc9c028482ae6a1c9 (patch) | |
| tree | 8bd26fb347a1672f597375da4099d784770ac9a3 /lib/text/diff | |
| parent | db97fff977fd18992bddc411b769893edb1dd86e (diff) | |
| download | pakakeh.go-9d05da3b79182f0fa63c268cc9c028482ae6a1c9.tar.xz | |
lib/text: realign struct for better size allocation
The realignment reduce the cost of the following struct,
* Chunk: from 16 to 8 bytes (-8)
* struct in TestChunk_MarshalJSON: from 40 to 32 bytes (-8)
* diff.LineChange: from 96 to 88 bytes (-8)
* Line: from 16 to 8 bytes (-8)
* struct in TestLine_MarshalJSON: from 40 to 32 bytes (-8)
Diffstat (limited to 'lib/text/diff')
| -rw-r--r-- | lib/text/diff/linechange.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/text/diff/linechange.go b/lib/text/diff/linechange.go index 0a659f9f..b9f18470 100644 --- a/lib/text/diff/linechange.go +++ b/lib/text/diff/linechange.go @@ -13,15 +13,21 @@ import ( // LineChange represent one change in text. type LineChange struct { - Old text.Line - New text.Line Adds text.Chunks Dels text.Chunks + + Old text.Line + New text.Line } // NewLineChange create a pointer to new LineChange object. func NewLineChange(old, new text.Line) *LineChange { - return &LineChange{old, new, text.Chunks{}, text.Chunks{}} + return &LineChange{ + Adds: text.Chunks{}, + Dels: text.Chunks{}, + Old: old, + New: new, + } } // String return formatted content of LineChange. |
