Skip to content

Commit

Permalink
huff0: Remove byteReader (#886)
Browse files Browse the repository at this point in the history
The only method that was used was remain, but that just returns the
input length as long as no other methods are called.
  • Loading branch information
greatroar authored Nov 24, 2023
1 parent 8f7526c commit e7c8ed1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 48 deletions.
44 changes: 0 additions & 44 deletions huff0/bytereader.go

This file was deleted.

4 changes: 2 additions & 2 deletions huff0/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (s *Scratch) validateTable(c cTable) bool {

// minTableLog provides the minimum logSize to safely represent a distribution.
func (s *Scratch) minTableLog() uint8 {
minBitsSrc := highBit32(uint32(s.br.remain())) + 1
minBitsSrc := highBit32(uint32(s.srcLen)) + 1
minBitsSymbols := highBit32(uint32(s.symbolLen-1)) + 2
if minBitsSrc < minBitsSymbols {
return uint8(minBitsSrc)
Expand All @@ -428,7 +428,7 @@ func (s *Scratch) minTableLog() uint8 {
func (s *Scratch) optimalTableLog() {
tableLog := s.TableLog
minBits := s.minTableLog()
maxBitsSrc := uint8(highBit32(uint32(s.br.remain()-1))) - 1
maxBitsSrc := uint8(highBit32(uint32(s.srcLen-1))) - 1
if maxBitsSrc < tableLog {
// Accuracy can be reduced
tableLog = maxBitsSrc
Expand Down
4 changes: 2 additions & 2 deletions huff0/huff0.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type Scratch struct {
// Decoders will return ErrMaxDecodedSizeExceeded is this limit is exceeded.
MaxDecodedSize int

br byteReader
srcLen int

// MaxSymbolValue will override the maximum symbol value of the next block.
MaxSymbolValue uint8
Expand Down Expand Up @@ -170,7 +170,7 @@ func (s *Scratch) prepare(in []byte) (*Scratch, error) {
if s.fse == nil {
s.fse = &fse.Scratch{}
}
s.br.init(in)
s.srcLen = len(in)

return s, nil
}
Expand Down

0 comments on commit e7c8ed1

Please sign in to comment.