compress: reordering fields to reduce struct sizes

Overall, there are 32 bytes reduced.

Change-Id: I455bf0874b33fa47719f42618e4800c7ff2a9e88
GitHub-Last-Rev: 7670344c4a
GitHub-Pull-Request: golang/go#67010
Reviewed-on: https://go-review.googlesource.com/c/go/+/581355
Reviewed-by: Joedian Reid <joedian@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
apocelipes 2024-04-24 09:59:02 +00:00 committed by Gopher Robot
parent 4370cfbdf9
commit 2dd82d97b6
4 changed files with 8 additions and 7 deletions

View File

@ -27,8 +27,8 @@ type reader struct {
blockCRC uint32 blockCRC uint32
wantBlockCRC uint32 wantBlockCRC uint32
setupDone bool // true if we have parsed the bzip2 header. setupDone bool // true if we have parsed the bzip2 header.
blockSize int // blockSize in bytes, i.e. 900 * 1000.
eof bool eof bool
blockSize int // blockSize in bytes, i.e. 900 * 1000.
c [256]uint // the ``C'' array for the inverse BWT. c [256]uint // the ``C'' array for the inverse BWT.
tt []uint32 // mirrors the ``tt'' array in the bzip2 source and contains the P array in the upper 24 bits. tt []uint32 // mirrors the ``tt'' array in the bzip2 source and contains the P array in the upper 24 bits.
tPos uint32 // Index of the next output byte in tt. tPos uint32 // Index of the next output byte in tt.

View File

@ -87,7 +87,6 @@ type compressor struct {
// compression algorithm // compression algorithm
fill func(*compressor, []byte) int // copy data to window fill func(*compressor, []byte) int // copy data to window
step func(*compressor) // process window step func(*compressor) // process window
sync bool // requesting flush
bestSpeed *deflateFast // Encoder for BestSpeed bestSpeed *deflateFast // Encoder for BestSpeed
// Input hash chains // Input hash chains
@ -107,6 +106,8 @@ type compressor struct {
blockStart int // window index where current tokens start blockStart int // window index where current tokens start
byteAvailable bool // if true, still need to process window[index-1]. byteAvailable bool // if true, still need to process window[index-1].
sync bool // requesting flush
// queued output tokens // queued output tokens
tokens []token tokens []token

View File

@ -30,11 +30,11 @@ type Writer struct {
w io.Writer w io.Writer
level int level int
wroteHeader bool wroteHeader bool
closed bool
buf [10]byte
compressor *flate.Writer compressor *flate.Writer
digest uint32 // CRC-32, IEEE polynomial (section 8) digest uint32 // CRC-32, IEEE polynomial (section 8)
size uint32 // Uncompressed size (section 2.3.1) size uint32 // Uncompressed size (section 2.3.1)
closed bool
buf [10]byte
err error err error
} }

View File

@ -36,15 +36,15 @@ const (
type Writer struct { type Writer struct {
// w is the writer that compressed bytes are written to. // w is the writer that compressed bytes are written to.
w writer w writer
// litWidth is the width in bits of literal codes.
litWidth uint
// order, write, bits, nBits and width are the state for // order, write, bits, nBits and width are the state for
// converting a code stream into a byte stream. // converting a code stream into a byte stream.
order Order order Order
write func(*Writer, uint32) error write func(*Writer, uint32) error
bits uint32
nBits uint nBits uint
width uint width uint
// litWidth is the width in bits of literal codes. bits uint32
litWidth uint
// hi is the code implied by the next code emission. // hi is the code implied by the next code emission.
// overflow is the code at which hi overflows the code width. // overflow is the code at which hi overflows the code width.
hi, overflow uint32 hi, overflow uint32