5
5
package flate
6
6
7
7
import (
8
- "encoding/binary"
9
8
"fmt"
10
9
"io"
11
10
"math"
11
+
12
+ "github.com/klauspost/compress/internal/le"
12
13
)
13
14
14
15
const (
@@ -438,7 +439,7 @@ func (w *huffmanBitWriter) writeOutBits() {
438
439
n := w .nbytes
439
440
440
441
// We over-write, but faster...
441
- binary . LittleEndian . PutUint64 (w .bytes [n :], bits )
442
+ le . Store64 (w .bytes [n :], bits )
442
443
n += 6
443
444
444
445
if n >= bufferFlushSize {
@@ -854,7 +855,7 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
854
855
bits |= c .code64 () << (nbits & 63 )
855
856
nbits += c .len ()
856
857
if nbits >= 48 {
857
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
858
+ le . Store64 (w .bytes [nbytes :], bits )
858
859
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
859
860
bits >>= 48
860
861
nbits -= 48
@@ -882,7 +883,7 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
882
883
bits |= c .code64 () << (nbits & 63 )
883
884
nbits += c .len ()
884
885
if nbits >= 48 {
885
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
886
+ le . Store64 (w .bytes [nbytes :], bits )
886
887
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
887
888
bits >>= 48
888
889
nbits -= 48
@@ -905,7 +906,7 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
905
906
bits |= uint64 (extraLength ) << (nbits & 63 )
906
907
nbits += extraLengthBits
907
908
if nbits >= 48 {
908
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
909
+ le . Store64 (w .bytes [nbytes :], bits )
909
910
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
910
911
bits >>= 48
911
912
nbits -= 48
@@ -931,7 +932,7 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
931
932
bits |= c .code64 () << (nbits & 63 )
932
933
nbits += c .len ()
933
934
if nbits >= 48 {
934
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
935
+ le . Store64 (w .bytes [nbytes :], bits )
935
936
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
936
937
bits >>= 48
937
938
nbits -= 48
@@ -953,7 +954,7 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
953
954
bits |= uint64 ((offset - (offsetComb >> 8 ))& matchOffsetOnlyMask ) << (nbits & 63 )
954
955
nbits += uint8 (offsetComb )
955
956
if nbits >= 48 {
956
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
957
+ le . Store64 (w .bytes [nbytes :], bits )
957
958
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
958
959
bits >>= 48
959
960
nbits -= 48
@@ -1107,7 +1108,7 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte, sync bool) {
1107
1108
// We must have at least 48 bits free.
1108
1109
if nbits >= 8 {
1109
1110
n := nbits >> 3
1110
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
1111
+ le . Store64 (w .bytes [nbytes :], bits )
1111
1112
bits >>= (n * 8 ) & 63
1112
1113
nbits -= n * 8
1113
1114
nbytes += n
@@ -1136,7 +1137,7 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte, sync bool) {
1136
1137
// Remaining...
1137
1138
for _ , t := range input {
1138
1139
if nbits >= 48 {
1139
- binary . LittleEndian . PutUint64 (w .bytes [nbytes :], bits )
1140
+ le . Store64 (w .bytes [nbytes :], bits )
1140
1141
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
1141
1142
bits >>= 48
1142
1143
nbits -= 48
0 commit comments