More staticcheck advice.
This commit is contained in:
parent
a61eb82231
commit
cf8bc3b664
29
decode.go
29
decode.go
|
@ -50,12 +50,6 @@ const (
|
|||
decoderErrorUnreachable = -31
|
||||
)
|
||||
|
||||
/** Options to be used with ::BrotliDecoderSetParameter. */
|
||||
const (
|
||||
decoderParamDisableRingBufferReallocation = 0
|
||||
decoderParamLargeWindow = 1
|
||||
)
|
||||
|
||||
const huffmanTableBits = 8
|
||||
|
||||
const huffmanTableMask = 0xFF
|
||||
|
@ -1094,10 +1088,8 @@ func decodeContextMap(context_map_size uint32, num_htrees *uint32, context_map_a
|
|||
Reads 3..54 bits. */
|
||||
func decodeBlockTypeAndLength(safe int, s *Reader, tree_type int) bool {
|
||||
var max_block_type uint32 = s.num_block_types[tree_type]
|
||||
var type_tree []huffmanCode
|
||||
type_tree = s.block_type_trees[tree_type*huffmanMaxSize258:]
|
||||
var len_tree []huffmanCode
|
||||
len_tree = s.block_len_trees[tree_type*huffmanMaxSize26:]
|
||||
type_tree := s.block_type_trees[tree_type*huffmanMaxSize258:]
|
||||
len_tree := s.block_len_trees[tree_type*huffmanMaxSize26:]
|
||||
var br *bitReader = &s.br
|
||||
var ringbuffer []uint32 = s.block_type_rb[tree_type*2:]
|
||||
var block_type uint32
|
||||
|
@ -1249,8 +1241,7 @@ func unwrittenBytes(s *Reader, wrap bool) uint {
|
|||
Returns BROTLI_DECODER_NEEDS_MORE_OUTPUT only if there is more output to push
|
||||
and either ring-buffer is as big as window size, or |force| is true. */
|
||||
func writeRingBuffer(s *Reader, available_out *uint, next_out *[]byte, total_out *uint, force bool) int {
|
||||
var start []byte
|
||||
start = s.ringbuffer[s.partial_pos_out&uint(s.ringbuffer_mask):]
|
||||
start := s.ringbuffer[s.partial_pos_out&uint(s.ringbuffer_mask):]
|
||||
var to_write uint = unwrittenBytes(s, true)
|
||||
var num_written uint = *available_out
|
||||
if num_written > to_write {
|
||||
|
@ -1381,8 +1372,7 @@ func copyUncompressedBlockToOutput(available_out *uint, next_out *[]byte, total_
|
|||
|
||||
case stateUncompressedWrite:
|
||||
{
|
||||
var result int
|
||||
result = writeRingBuffer(s, available_out, next_out, total_out, false)
|
||||
result := writeRingBuffer(s, available_out, next_out, total_out, false)
|
||||
if result != decoderSuccess {
|
||||
return result
|
||||
}
|
||||
|
@ -1900,8 +1890,7 @@ CommandPostDecodeLiterals:
|
|||
}
|
||||
|
||||
if transform_idx < int(trans.num_transforms) {
|
||||
var word []byte
|
||||
word = words.data[offset:]
|
||||
word := words.data[offset:]
|
||||
var len int = i
|
||||
if transform_idx == int(trans.cutOffTransforms[0]) {
|
||||
copy(s.ringbuffer[pos:], word[:uint(len)])
|
||||
|
@ -1923,10 +1912,8 @@ CommandPostDecodeLiterals:
|
|||
}
|
||||
} else {
|
||||
var src_start int = (pos - s.distance_code) & s.ringbuffer_mask
|
||||
var copy_dst []byte
|
||||
copy_dst = s.ringbuffer[pos:]
|
||||
var copy_src []byte
|
||||
copy_src = s.ringbuffer[src_start:]
|
||||
copy_dst := s.ringbuffer[pos:]
|
||||
copy_src := s.ringbuffer[src_start:]
|
||||
var dst_end int = pos + i
|
||||
var src_end int = src_start + i
|
||||
|
||||
|
@ -2463,8 +2450,6 @@ func decoderDecompressStream(s *Reader, available_in *uint, next_in *[]byte, ava
|
|||
} else {
|
||||
s.state = stateCommandBegin
|
||||
}
|
||||
|
||||
break
|
||||
} else if s.state == stateCommandPostWrite2 {
|
||||
s.state = stateCommandPostWrapCopy /* BROTLI_STATE_COMMAND_INNER_WRITE */
|
||||
} else {
|
||||
|
|
|
@ -920,8 +920,7 @@ func encodeData(s *Writer, is_last bool, force_flush bool) bool {
|
|||
REQUIRED: |header| should be 8-byte aligned and at least 16 bytes long.
|
||||
REQUIRED: |block_size| <= (1 << 24). */
|
||||
func writeMetadataHeader(s *Writer, block_size uint, header []byte) uint {
|
||||
var storage_ix uint
|
||||
storage_ix = uint(s.last_bytes_bits_)
|
||||
storage_ix := uint(s.last_bytes_bits_)
|
||||
header[0] = byte(s.last_bytes_)
|
||||
header[1] = byte(s.last_bytes_ >> 8)
|
||||
s.last_bytes_ = 0
|
||||
|
|
2
hash.go
2
hash.go
|
@ -29,8 +29,6 @@ type hasherHandle interface {
|
|||
Store(data []byte, mask uint, ix uint)
|
||||
}
|
||||
|
||||
type score_t uint
|
||||
|
||||
const kCutoffTransformsCount uint32 = 10
|
||||
|
||||
/* 0, 12, 27, 23, 42, 63, 56, 48, 59, 64 */
|
||||
|
|
|
@ -110,8 +110,7 @@ func (h *hashForgetfulChain) Prepare(one_shot bool, input_size uint, data []byte
|
|||
func (h *hashForgetfulChain) Store(data []byte, mask uint, ix uint) {
|
||||
var key uint = h.HashBytes(data[ix&mask:])
|
||||
var bank uint = key & (h.numBanks - 1)
|
||||
var idx uint
|
||||
idx = uint(h.free_slot_idx[bank]) & ((1 << h.bankBits) - 1)
|
||||
idx := uint(h.free_slot_idx[bank]) & ((1 << h.bankBits) - 1)
|
||||
h.free_slot_idx[bank]++
|
||||
var delta uint = ix - uint(h.addr[key])
|
||||
h.tiny_hash[uint16(ix)] = byte(key)
|
||||
|
|
|
@ -48,7 +48,6 @@ type hashRolling struct {
|
|||
state uint32
|
||||
table []uint32
|
||||
next_ix uint
|
||||
chunk_len uint32
|
||||
factor uint32
|
||||
factor_remove uint32
|
||||
}
|
||||
|
|
|
@ -77,8 +77,7 @@ func findAllStaticDictionaryMatches(dict *encoderDictionary, data []byte, min_le
|
|||
var offset uint = uint(dict.buckets[hash(data)])
|
||||
var end bool = offset == 0
|
||||
for !end {
|
||||
var w dictWord
|
||||
w = dict.dict_words[offset]
|
||||
w := dict.dict_words[offset]
|
||||
offset++
|
||||
var l uint = uint(w.len) & 0x1F
|
||||
var n uint = uint(1) << dict.words.size_bits_by_length[l]
|
||||
|
@ -431,8 +430,7 @@ func findAllStaticDictionaryMatches(dict *encoderDictionary, data []byte, min_le
|
|||
var offset uint = uint(dict.buckets[hash(data[1:])])
|
||||
var end bool = offset == 0
|
||||
for !end {
|
||||
var w dictWord
|
||||
w = dict.dict_words[offset]
|
||||
w := dict.dict_words[offset]
|
||||
offset++
|
||||
var l uint = uint(w.len) & 0x1F
|
||||
var n uint = uint(1) << dict.words.size_bits_by_length[l]
|
||||
|
@ -596,8 +594,7 @@ func findAllStaticDictionaryMatches(dict *encoderDictionary, data []byte, min_le
|
|||
var offset uint = uint(dict.buckets[hash(data[2:])])
|
||||
var end bool = offset == 0
|
||||
for !end {
|
||||
var w dictWord
|
||||
w = dict.dict_words[offset]
|
||||
w := dict.dict_words[offset]
|
||||
offset++
|
||||
var l uint = uint(w.len) & 0x1F
|
||||
var n uint = uint(1) << dict.words.size_bits_by_length[l]
|
||||
|
@ -629,8 +626,7 @@ func findAllStaticDictionaryMatches(dict *encoderDictionary, data []byte, min_le
|
|||
var offset uint = uint(dict.buckets[hash(data[5:])])
|
||||
var end bool = offset == 0
|
||||
for !end {
|
||||
var w dictWord
|
||||
w = dict.dict_words[offset]
|
||||
w := dict.dict_words[offset]
|
||||
offset++
|
||||
var l uint = uint(w.len) & 0x1F
|
||||
var n uint = uint(1) << dict.words.size_bits_by_length[l]
|
||||
|
|
|
@ -58,8 +58,7 @@ func isMostlyUTF8(data []byte, pos uint, mask uint, length uint, min_fraction fl
|
|||
var i uint = 0
|
||||
for i < length {
|
||||
var symbol int
|
||||
var current_data []byte
|
||||
current_data = data[(pos+i)&mask:]
|
||||
current_data := data[(pos+i)&mask:]
|
||||
var bytes_read uint = parseAsUTF8(&symbol, current_data, length-i)
|
||||
i += bytes_read
|
||||
if symbol < 0x110000 {
|
||||
|
|
Loading…
Reference in New Issue