File tree 1 file changed +5
-22
lines changed
1 file changed +5
-22
lines changed Original file line number Diff line number Diff line change 9
9
"fmt"
10
10
"math"
11
11
"math/bits"
12
+ "slices"
12
13
13
14
"github.com/klauspost/compress/huff0"
14
15
)
@@ -457,16 +458,7 @@ func fuzzFseEncoder(data []byte) int {
457
458
// All 0
458
459
return 0
459
460
}
460
- maxCount := func (a []uint32 ) int {
461
- var max uint32
462
- for _ , v := range a {
463
- if v > max {
464
- max = v
465
- }
466
- }
467
- return int (max )
468
- }
469
- cnt := maxCount (hist [:maxSym ])
461
+ cnt := int (slices .Max (hist [:maxSym ]))
470
462
if cnt == len (data ) {
471
463
// RLE
472
464
return 0
@@ -884,15 +876,6 @@ func (b *blockEnc) genCodes() {
884
876
}
885
877
}
886
878
}
887
- maxCount := func (a []uint32 ) int {
888
- var max uint32
889
- for _ , v := range a {
890
- if v > max {
891
- max = v
892
- }
893
- }
894
- return int (max )
895
- }
896
879
if debugAsserts && mlMax > maxMatchLengthSymbol {
897
880
panic (fmt .Errorf ("mlMax > maxMatchLengthSymbol (%d)" , mlMax ))
898
881
}
@@ -903,7 +886,7 @@ func (b *blockEnc) genCodes() {
903
886
panic (fmt .Errorf ("llMax > maxLiteralLengthSymbol (%d)" , llMax ))
904
887
}
905
888
906
- b .coders .mlEnc .HistogramFinished (mlMax , maxCount ( mlH [:mlMax + 1 ]))
907
- b .coders .ofEnc .HistogramFinished (ofMax , maxCount ( ofH [:ofMax + 1 ]))
908
- b .coders .llEnc .HistogramFinished (llMax , maxCount ( llH [:llMax + 1 ]))
889
+ b .coders .mlEnc .HistogramFinished (mlMax , int ( slices . Max ( mlH [:mlMax + 1 ]) ))
890
+ b .coders .ofEnc .HistogramFinished (ofMax , int ( slices . Max ( ofH [:ofMax + 1 ]) ))
891
+ b .coders .llEnc .HistogramFinished (llMax , int ( slices . Max ( llH [:llMax + 1 ]) ))
909
892
}
You can’t perform that action at this time.
0 commit comments