Skip to content

Commit e7c8ed1

Browse files
authored
huff0: Remove byteReader (#886)
The only method that was used was remain, but that just returns the input length as long as no other methods are called.
1 parent 8f7526c commit e7c8ed1

File tree

3 files changed

+4
-48
lines changed

3 files changed

+4
-48
lines changed

huff0/bytereader.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

huff0/compress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func (s *Scratch) validateTable(c cTable) bool {
416416

417417
// minTableLog provides the minimum logSize to safely represent a distribution.
418418
func (s *Scratch) minTableLog() uint8 {
419-
minBitsSrc := highBit32(uint32(s.br.remain())) + 1
419+
minBitsSrc := highBit32(uint32(s.srcLen)) + 1
420420
minBitsSymbols := highBit32(uint32(s.symbolLen-1)) + 2
421421
if minBitsSrc < minBitsSymbols {
422422
return uint8(minBitsSrc)
@@ -428,7 +428,7 @@ func (s *Scratch) minTableLog() uint8 {
428428
func (s *Scratch) optimalTableLog() {
429429
tableLog := s.TableLog
430430
minBits := s.minTableLog()
431-
maxBitsSrc := uint8(highBit32(uint32(s.br.remain()-1))) - 1
431+
maxBitsSrc := uint8(highBit32(uint32(s.srcLen-1))) - 1
432432
if maxBitsSrc < tableLog {
433433
// Accuracy can be reduced
434434
tableLog = maxBitsSrc

huff0/huff0.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type Scratch struct {
8888
// Decoders will return ErrMaxDecodedSizeExceeded is this limit is exceeded.
8989
MaxDecodedSize int
9090

91-
br byteReader
91+
srcLen int
9292

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

175175
return s, nil
176176
}

0 commit comments

Comments
 (0)