summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/klauspost/compress/fse
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-03-09 22:48:00 +0100
committerGitHub <noreply@github.com>2023-03-09 22:48:00 +0100
commit08779c29099e8940493df56d28d8aa131ac8342e (patch)
tree7ad8ce25cf371e582137e1706dd671a6bf4342d0 /vendor/github.com/klauspost/compress/fse
parentd5f9cdf912d43cd2a5cb243e086fbdab9a9073b0 (diff)
downloadmatterbridge-msglm-08779c29099e8940493df56d28d8aa131ac8342e.tar.gz
matterbridge-msglm-08779c29099e8940493df56d28d8aa131ac8342e.tar.bz2
matterbridge-msglm-08779c29099e8940493df56d28d8aa131ac8342e.zip
Update dependencies (#2007)
* Update dependencies
Diffstat (limited to 'vendor/github.com/klauspost/compress/fse')
-rw-r--r--vendor/github.com/klauspost/compress/fse/compress.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/vendor/github.com/klauspost/compress/fse/compress.go b/vendor/github.com/klauspost/compress/fse/compress.go
index 6f341914..dac97e58 100644
--- a/vendor/github.com/klauspost/compress/fse/compress.go
+++ b/vendor/github.com/klauspost/compress/fse/compress.go
@@ -146,54 +146,51 @@ func (s *Scratch) compress(src []byte) error {
c1.encodeZero(tt[src[ip-2]])
ip -= 2
}
+ src = src[:ip]
// Main compression loop.
switch {
case !s.zeroBits && s.actualTableLog <= 8:
// We can encode 4 symbols without requiring a flush.
// We do not need to check if any output is 0 bits.
- for ip >= 4 {
+ for ; len(src) >= 4; src = src[:len(src)-4] {
s.bw.flush32()
- v3, v2, v1, v0 := src[ip-4], src[ip-3], src[ip-2], src[ip-1]
+ v3, v2, v1, v0 := src[len(src)-4], src[len(src)-3], src[len(src)-2], src[len(src)-1]
c2.encode(tt[v0])
c1.encode(tt[v1])
c2.encode(tt[v2])
c1.encode(tt[v3])
- ip -= 4
}
case !s.zeroBits:
// We do not need to check if any output is 0 bits.
- for ip >= 4 {
+ for ; len(src) >= 4; src = src[:len(src)-4] {
s.bw.flush32()
- v3, v2, v1, v0 := src[ip-4], src[ip-3], src[ip-2], src[ip-1]
+ v3, v2, v1, v0 := src[len(src)-4], src[len(src)-3], src[len(src)-2], src[len(src)-1]
c2.encode(tt[v0])
c1.encode(tt[v1])
s.bw.flush32()
c2.encode(tt[v2])
c1.encode(tt[v3])
- ip -= 4
}
case s.actualTableLog <= 8:
// We can encode 4 symbols without requiring a flush
- for ip >= 4 {
+ for ; len(src) >= 4; src = src[:len(src)-4] {
s.bw.flush32()
- v3, v2, v1, v0 := src[ip-4], src[ip-3], src[ip-2], src[ip-1]
+ v3, v2, v1, v0 := src[len(src)-4], src[len(src)-3], src[len(src)-2], src[len(src)-1]
c2.encodeZero(tt[v0])
c1.encodeZero(tt[v1])
c2.encodeZero(tt[v2])
c1.encodeZero(tt[v3])
- ip -= 4
}
default:
- for ip >= 4 {
+ for ; len(src) >= 4; src = src[:len(src)-4] {
s.bw.flush32()
- v3, v2, v1, v0 := src[ip-4], src[ip-3], src[ip-2], src[ip-1]
+ v3, v2, v1, v0 := src[len(src)-4], src[len(src)-3], src[len(src)-2], src[len(src)-1]
c2.encodeZero(tt[v0])
c1.encodeZero(tt[v1])
s.bw.flush32()
c2.encodeZero(tt[v2])
c1.encodeZero(tt[v3])
- ip -= 4
}
}
@@ -459,15 +456,17 @@ func (s *Scratch) countSimple(in []byte) (max int) {
for _, v := range in {
s.count[v]++
}
- m := uint32(0)
+ m, symlen := uint32(0), s.symbolLen
for i, v := range s.count[:] {
+ if v == 0 {
+ continue
+ }
if v > m {
m = v
}
- if v > 0 {
- s.symbolLen = uint16(i) + 1
- }
+ symlen = uint16(i) + 1
}
+ s.symbolLen = symlen
return int(m)
}