Skip to content

Commit

Permalink
compress: reordering fields to reduce struct sizes
Browse files Browse the repository at this point in the history
Overall, there are 32 bytes reduced.
  • Loading branch information
apocelipes committed Apr 24, 2024
1 parent 960fa9b commit 7670344
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compress/bzip2/bzip2.go
Expand Up @@ -27,8 +27,8 @@ type reader struct {
blockCRC uint32
wantBlockCRC uint32
setupDone bool // true if we have parsed the bzip2 header.
blockSize int // blockSize in bytes, i.e. 900 * 1000.
eof bool
blockSize int // blockSize in bytes, i.e. 900 * 1000.
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.
tPos uint32 // Index of the next output byte in tt.
Expand Down
3 changes: 2 additions & 1 deletion src/compress/flate/deflate.go
Expand Up @@ -87,7 +87,6 @@ type compressor struct {
// compression algorithm
fill func(*compressor, []byte) int // copy data to window
step func(*compressor) // process window
sync bool // requesting flush
bestSpeed *deflateFast // Encoder for BestSpeed

// Input hash chains
Expand All @@ -107,6 +106,8 @@ type compressor struct {
blockStart int // window index where current tokens start
byteAvailable bool // if true, still need to process window[index-1].

sync bool // requesting flush

// queued output tokens
tokens []token

Expand Down
4 changes: 2 additions & 2 deletions src/compress/gzip/gzip.go
Expand Up @@ -30,11 +30,11 @@ type Writer struct {
w io.Writer
level int
wroteHeader bool
closed bool
buf [10]byte
compressor *flate.Writer
digest uint32 // CRC-32, IEEE polynomial (section 8)
size uint32 // Uncompressed size (section 2.3.1)
closed bool
buf [10]byte
err error
}

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

0 comments on commit 7670344

Please sign in to comment.