From baf76ed614a3f61d8abcfaa13f2f4448038f1e8d Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Sun, 12 Mar 2023 20:37:10 -0700 Subject: [PATCH] archive: fix order of struct items to reduce memory usage Found by fieldalignment: archive.go:46:14: struct with 88 pointer bytes could be 56 archive.go:66:18: struct with 24 pointer bytes could be 16 The first one probably doesn't matter that much, there's only like 2 of those objects that are instantiated at runtime. However, there are many ArchiveItems (hundreds or more depending on the archives compositions) --- internal/archive/archive.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/archive/archive.go b/internal/archive/archive.go index 7f00949..14d92ac 100644 --- a/internal/archive/archive.go +++ b/internal/archive/archive.go @@ -44,11 +44,11 @@ const ( ) type Archive struct { - items archiveItems cpioWriter *cpio.Writer buf *bytes.Buffer compress_format CompressFormat compress_level CompressLevel + items archiveItems } func New(format CompressFormat, level CompressLevel) (*Archive, error) { @@ -64,8 +64,8 @@ func New(format CompressFormat, level CompressLevel) (*Archive, error) { } type archiveItem struct { - sourcePath string header *cpio.Header + sourcePath string } type archiveItems struct {