Note: We keep splitio/go-client untouched
because the dependency is broken.

See https://github.com/mattermost/mattermost-server/pull/18604

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2021-11-24 19:45:28 +05:30
коммит произвёл GitHub
родитель fd8fea804b
Коммит 189d447591
362 изменённых файлов: 66284 добавлений и 19348 удалений

162
vendor/github.com/andybalholm/brotli/cluster_command.go сгенерированный поставляемый
Просмотреть файл

@@ -1,7 +1,5 @@
package brotli
import "math"
/* Copyright 2013 Google Inc. All Rights Reserved.
Distributed under MIT license.
@@ -164,163 +162,3 @@ func histogramBitCostDistanceCommand(histogram *histogramCommand, candidate *his
return populationCostCommand(&tmp) - candidate.bit_cost_
}
}
/* Find the best 'out' histogram for each of the 'in' histograms.
When called, clusters[0..num_clusters) contains the unique values from
symbols[0..in_size), but this property is not preserved in this function.
Note: we assume that out[]->bit_cost_ is already up-to-date. */
func histogramRemapCommand(in []histogramCommand, in_size uint, clusters []uint32, num_clusters uint, out []histogramCommand, symbols []uint32) {
var i uint
for i = 0; i < in_size; i++ {
var best_out uint32
if i == 0 {
best_out = symbols[0]
} else {
best_out = symbols[i-1]
}
var best_bits float64 = histogramBitCostDistanceCommand(&in[i], &out[best_out])
var j uint
for j = 0; j < num_clusters; j++ {
var cur_bits float64 = histogramBitCostDistanceCommand(&in[i], &out[clusters[j]])
if cur_bits < best_bits {
best_bits = cur_bits
best_out = clusters[j]
}
}
symbols[i] = best_out
}
/* Recompute each out based on raw and symbols. */
for i = 0; i < num_clusters; i++ {
histogramClearCommand(&out[clusters[i]])
}
for i = 0; i < in_size; i++ {
histogramAddHistogramCommand(&out[symbols[i]], &in[i])
}
}
/* Reorders elements of the out[0..length) array and changes values in
symbols[0..length) array in the following way:
* when called, symbols[] contains indexes into out[], and has N unique
values (possibly N < length)
* on return, symbols'[i] = f(symbols[i]) and
out'[symbols'[i]] = out[symbols[i]], for each 0 <= i < length,
where f is a bijection between the range of symbols[] and [0..N), and
the first occurrences of values in symbols'[i] come in consecutive
increasing order.
Returns N, the number of unique values in symbols[]. */
var histogramReindexCommand_kInvalidIndex uint32 = math.MaxUint32
func histogramReindexCommand(out []histogramCommand, symbols []uint32, length uint) uint {
var new_index []uint32 = make([]uint32, length)
var next_index uint32
var tmp []histogramCommand
var i uint
for i = 0; i < length; i++ {
new_index[i] = histogramReindexCommand_kInvalidIndex
}
next_index = 0
for i = 0; i < length; i++ {
if new_index[symbols[i]] == histogramReindexCommand_kInvalidIndex {
new_index[symbols[i]] = next_index
next_index++
}
}
/* TODO: by using idea of "cycle-sort" we can avoid allocation of
tmp and reduce the number of copying by the factor of 2. */
tmp = make([]histogramCommand, next_index)
next_index = 0
for i = 0; i < length; i++ {
if new_index[symbols[i]] == next_index {
tmp[next_index] = out[symbols[i]]
next_index++
}
symbols[i] = new_index[symbols[i]]
}
new_index = nil
for i = 0; uint32(i) < next_index; i++ {
out[i] = tmp[i]
}
tmp = nil
return uint(next_index)
}
func clusterHistogramsCommand(in []histogramCommand, in_size uint, max_histograms uint, out []histogramCommand, out_size *uint, histogram_symbols []uint32) {
var cluster_size []uint32 = make([]uint32, in_size)
var clusters []uint32 = make([]uint32, in_size)
var num_clusters uint = 0
var max_input_histograms uint = 64
var pairs_capacity uint = max_input_histograms * max_input_histograms / 2
var pairs []histogramPair = make([]histogramPair, (pairs_capacity + 1))
var i uint
/* For the first pass of clustering, we allow all pairs. */
for i = 0; i < in_size; i++ {
cluster_size[i] = 1
}
for i = 0; i < in_size; i++ {
out[i] = in[i]
out[i].bit_cost_ = populationCostCommand(&in[i])
histogram_symbols[i] = uint32(i)
}
for i = 0; i < in_size; i += max_input_histograms {
var num_to_combine uint = brotli_min_size_t(in_size-i, max_input_histograms)
var num_new_clusters uint
var j uint
for j = 0; j < num_to_combine; j++ {
clusters[num_clusters+j] = uint32(i + j)
}
num_new_clusters = histogramCombineCommand(out, cluster_size, histogram_symbols[i:], clusters[num_clusters:], pairs, num_to_combine, num_to_combine, max_histograms, pairs_capacity)
num_clusters += num_new_clusters
}
{
/* For the second pass, we limit the total number of histogram pairs.
After this limit is reached, we only keep searching for the best pair. */
var max_num_pairs uint = brotli_min_size_t(64*num_clusters, (num_clusters/2)*num_clusters)
if pairs_capacity < (max_num_pairs + 1) {
var _new_size uint
if pairs_capacity == 0 {
_new_size = max_num_pairs + 1
} else {
_new_size = pairs_capacity
}
var new_array []histogramPair
for _new_size < (max_num_pairs + 1) {
_new_size *= 2
}
new_array = make([]histogramPair, _new_size)
if pairs_capacity != 0 {
copy(new_array, pairs[:pairs_capacity])
}
pairs = new_array
pairs_capacity = _new_size
}
/* Collapse similar histograms. */
num_clusters = histogramCombineCommand(out, cluster_size, histogram_symbols, clusters, pairs, num_clusters, in_size, max_histograms, max_num_pairs)
}
pairs = nil
cluster_size = nil
/* Find the optimal map from original histograms to the final ones. */
histogramRemapCommand(in, in_size, clusters, num_clusters, out, histogram_symbols)
clusters = nil
/* Convert the context map to a canonical form. */
*out_size = histogramReindexCommand(out, histogram_symbols, in_size)
}

2
vendor/github.com/andybalholm/brotli/compress_fragment.go сгенерированный поставляемый
Просмотреть файл

@@ -604,7 +604,7 @@ emit_commands:
assert(candidate < ip)
table[hash] = int(ip - base_ip)
if !(!isMatch5(in[ip:], in[candidate:])) {
if isMatch5(in[ip:], in[candidate:]) {
break
}
}

60
vendor/github.com/andybalholm/brotli/decode.go сгенерированный поставляемый
Просмотреть файл

@@ -50,21 +50,6 @@ const (
decoderErrorUnreachable = -31
)
/**
* The value of the last error code, negative integer.
*
* All other error code values are in the range from ::lastErrorCode
* to @c -1. There are also 4 other possible non-error codes @c 0 .. @c 3 in
* ::BrotliDecoderErrorCode enumeration.
*/
const lastErrorCode = decoderErrorUnreachable
/** Options to be used with ::BrotliDecoderSetParameter. */
const (
decoderParamDisableRingBufferReallocation = 0
decoderParamLargeWindow = 1
)
const huffmanTableBits = 8
const huffmanTableMask = 0xFF
@@ -81,28 +66,6 @@ var kCodeLengthPrefixLength = [16]byte{2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 3, 2, 2,
var kCodeLengthPrefixValue = [16]byte{0, 4, 3, 2, 0, 4, 3, 1, 0, 4, 3, 2, 0, 4, 3, 5}
func decoderSetParameter(state *Reader, p int, value uint32) bool {
if state.state != stateUninited {
return false
}
switch p {
case decoderParamDisableRingBufferReallocation:
if !(value == 0) {
state.canny_ringbuffer_allocation = 0
} else {
state.canny_ringbuffer_allocation = 1
}
return true
case decoderParamLargeWindow:
state.large_window = (!(value == 0))
return true
default:
return false
}
}
/* Saves error code and converts it to BrotliDecoderResult. */
func saveErrorCode(s *Reader, e int) int {
s.error_code = int(e)
@@ -1125,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
@@ -1280,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 {
@@ -1412,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
}
@@ -1931,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)])
@@ -1954,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
@@ -2494,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 {

3
vendor/github.com/andybalholm/brotli/encode.go сгенерированный поставляемый
Просмотреть файл

@@ -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

16
vendor/github.com/andybalholm/brotli/fast_log.go сгенерированный поставляемый
Просмотреть файл

@@ -1,6 +1,9 @@
package brotli
import "math"
import (
"math"
"math/bits"
)
/* Copyright 2013 Google Inc. All Rights Reserved.
@@ -11,16 +14,7 @@ import "math"
/* Utilities for fast computation of logarithms. */
func log2FloorNonZero(n uint) uint32 {
/* TODO: generalize and move to platform.h */
var result uint32 = 0
for {
n >>= 1
if n == 0 {
break
}
result++
}
return result
return uint32(bits.Len(n)) - 1
}
/* A lookup table for small values of log2(int) to be used in entropy

2
vendor/github.com/andybalholm/brotli/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 */

3
vendor/github.com/andybalholm/brotli/hash_forgetful_chain.go сгенерированный поставляемый
Просмотреть файл

@@ -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)

1
vendor/github.com/andybalholm/brotli/hash_rolling.go сгенерированный поставляемый
Просмотреть файл

@@ -48,7 +48,6 @@ type hashRolling struct {
state uint32
table []uint32
next_ix uint
chunk_len uint32
factor uint32
factor_remove uint32
}

4
vendor/github.com/andybalholm/brotli/http.go сгенерированный поставляемый
Просмотреть файл

@@ -180,8 +180,8 @@ func init() {
var t octetType
isCtl := c <= 31 || c == 127
isChar := 0 <= c && c <= 127
isSeparator := strings.IndexRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) >= 0
if strings.IndexRune(" \t\r\n", rune(c)) >= 0 {
isSeparator := strings.ContainsRune(" \t\"(),/:;<=>?@[]\\{}", rune(c))
if strings.ContainsRune(" \t\r\n", rune(c)) {
t |= isSpace
}
if isChar && !isCtl && !isSeparator {

12
vendor/github.com/andybalholm/brotli/static_dict.go сгенерированный поставляемый
Просмотреть файл

@@ -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]

3
vendor/github.com/andybalholm/brotli/utf8_util.go сгенерированный поставляемый
Просмотреть файл

@@ -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 {

1
vendor/github.com/andybalholm/brotli/writer.go сгенерированный поставляемый
Просмотреть файл

@@ -61,6 +61,7 @@ func (w *Writer) Reset(dst io.Writer) {
w.params.lgwin = uint(w.options.LGWin)
}
w.dst = dst
w.err = nil
}
func (w *Writer) writeChunk(p []byte, op int) (n int, err error) {