Macaron 1.5 (#12596)
* update macaron to v1.5 of fork * update macaron to v1.5 of fork * test gzip PR * add push method impl to context_tests * use proper gzip commit Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
211321fb93
commit
c5d5d63c9c
53 changed files with 2622 additions and 665 deletions
53
vendor/github.com/klauspost/compress/zstd/decoder.go
generated
vendored
53
vendor/github.com/klauspost/compress/zstd/decoder.go
generated
vendored
|
@ -23,17 +23,15 @@ type Decoder struct {
|
|||
// Unreferenced decoders, ready for use.
|
||||
decoders chan *blockDec
|
||||
|
||||
// Unreferenced decoders, ready for use.
|
||||
frames chan *frameDec
|
||||
|
||||
// Streams ready to be decoded.
|
||||
stream chan decodeStream
|
||||
|
||||
// Current read position used for Reader functionality.
|
||||
current decoderState
|
||||
|
||||
// Custom dictionaries
|
||||
dicts map[uint32]struct{}
|
||||
// Custom dictionaries.
|
||||
// Always uses copies.
|
||||
dicts map[uint32]dict
|
||||
|
||||
// streamWg is the waitgroup for all streams
|
||||
streamWg sync.WaitGroup
|
||||
|
@ -66,7 +64,7 @@ var (
|
|||
// A Decoder can be used in two modes:
|
||||
//
|
||||
// 1) As a stream, or
|
||||
// 2) For stateless decoding using DecodeAll or DecodeBuffer.
|
||||
// 2) For stateless decoding using DecodeAll.
|
||||
//
|
||||
// Only a single stream can be decoded concurrently, but the same decoder
|
||||
// can run multiple concurrent stateless decodes. It is even possible to
|
||||
|
@ -87,12 +85,19 @@ func NewReader(r io.Reader, opts ...DOption) (*Decoder, error) {
|
|||
d.current.output = make(chan decodeOutput, d.o.concurrent)
|
||||
d.current.flushed = true
|
||||
|
||||
// Transfer option dicts.
|
||||
d.dicts = make(map[uint32]dict, len(d.o.dicts))
|
||||
for _, dc := range d.o.dicts {
|
||||
d.dicts[dc.id] = dc
|
||||
}
|
||||
d.o.dicts = nil
|
||||
|
||||
// Create decoders
|
||||
d.decoders = make(chan *blockDec, d.o.concurrent)
|
||||
d.frames = make(chan *frameDec, d.o.concurrent)
|
||||
for i := 0; i < d.o.concurrent; i++ {
|
||||
d.frames <- newFrameDec(d.o)
|
||||
d.decoders <- newBlockDec(d.o.lowMem)
|
||||
dec := newBlockDec(d.o.lowMem)
|
||||
dec.localFrame = newFrameDec(d.o)
|
||||
d.decoders <- dec
|
||||
}
|
||||
|
||||
if r == nil {
|
||||
|
@ -169,7 +174,12 @@ func (d *Decoder) Reset(r io.Reader) error {
|
|||
println("*bytes.Buffer detected, doing sync decode, len:", bb.Len())
|
||||
}
|
||||
b := bb.Bytes()
|
||||
dst, err := d.DecodeAll(b, nil)
|
||||
var dst []byte
|
||||
if cap(d.current.b) > 0 {
|
||||
dst = d.current.b
|
||||
}
|
||||
|
||||
dst, err := d.DecodeAll(b, dst[:0])
|
||||
if err == nil {
|
||||
err = io.EOF
|
||||
}
|
||||
|
@ -277,23 +287,31 @@ func (d *Decoder) DecodeAll(input, dst []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
// Grab a block decoder and frame decoder.
|
||||
block, frame := <-d.decoders, <-d.frames
|
||||
block := <-d.decoders
|
||||
frame := block.localFrame
|
||||
defer func() {
|
||||
if debug {
|
||||
printf("re-adding decoder: %p", block)
|
||||
}
|
||||
d.decoders <- block
|
||||
frame.rawInput = nil
|
||||
frame.bBuf = nil
|
||||
d.frames <- frame
|
||||
d.decoders <- block
|
||||
}()
|
||||
frame.bBuf = input
|
||||
|
||||
for {
|
||||
frame.history.reset()
|
||||
err := frame.reset(&frame.bBuf)
|
||||
if err == io.EOF {
|
||||
return dst, nil
|
||||
}
|
||||
if frame.DictionaryID != nil {
|
||||
dict, ok := d.dicts[*frame.DictionaryID]
|
||||
if !ok {
|
||||
return nil, ErrUnknownDictionary
|
||||
}
|
||||
frame.history.setDict(&dict)
|
||||
}
|
||||
if err != nil {
|
||||
return dst, err
|
||||
}
|
||||
|
@ -456,10 +474,19 @@ func (d *Decoder) startStreamDecoder(inStream chan decodeStream) {
|
|||
br := readerWrapper{r: stream.r}
|
||||
decodeStream:
|
||||
for {
|
||||
frame.history.reset()
|
||||
err := frame.reset(&br)
|
||||
if debug && err != nil {
|
||||
println("Frame decoder returned", err)
|
||||
}
|
||||
if err == nil && frame.DictionaryID != nil {
|
||||
dict, ok := d.dicts[*frame.DictionaryID]
|
||||
if !ok {
|
||||
err = ErrUnknownDictionary
|
||||
} else {
|
||||
frame.history.setDict(&dict)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
stream.output <- decodeOutput{
|
||||
err: err,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue