package flate
import (
"io"
"github.com/andybalholm/brotli/matchfinder"
)
func NewWriter (w io .Writer , level int ) *matchfinder .Writer {
return newWriter (w , level , NewEncoder ())
}
func NewGZIPWriter (w io .Writer , level int ) *matchfinder .Writer {
return newWriter (w , level , NewGZIPEncoder ())
}
func newWriter (w io .Writer , level int , e matchfinder .Encoder ) *matchfinder .Writer {
var mf matchfinder .MatchFinder
if level < 2 {
mf = &matchfinder .ZFast {MaxDistance : 1 << 15 }
} else if level == 2 {
mf = &matchfinder .ZDFast {MaxDistance : 1 << 15 }
} else if level == 3 {
mf = &matchfinder .ZM {MaxDistance : 1 << 15 }
} else if level == 4 {
mf = &matchfinder .Trio {MaxDistance : 1 << 15 }
} else if level < 8 {
chainLen := 32
switch level {
case 5 :
chainLen = 8
case 6 :
chainLen = 16
}
mf = &matchfinder .M4 {
MaxDistance : 1 << 15 ,
ChainLength : chainLen ,
HashLen : 5 ,
DistanceBitCost : 66 ,
}
} else {
chainLen := 32
hashLen := 5
if level == 8 {
chainLen = 4
}
mf = &matchfinder .Pathfinder {
MaxDistance : 1 << 15 ,
ChainLength : chainLen ,
HashLen : hashLen ,
}
}
return &matchfinder .Writer {
Dest : w ,
MatchFinder : mf ,
Encoder : e ,
BlockSize : 1 << 16 ,
}
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .