mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Reset zlib reader instead of re-opening it before reading meta data from block. Speeds up decoding of blocks significantly. Using a sync.Pool will seed it up even more.
This commit is contained in:
parent
076ca9fad6
commit
ab1a86384b
@ -86,12 +86,12 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
||||
if zr, err = zlib.NewReader(&buf); err != nil {
|
||||
return
|
||||
}
|
||||
defer zr.Close()
|
||||
|
||||
mapContent := make([]byte, uncompressedLen)
|
||||
|
||||
var k int
|
||||
k, err = io.ReadFull(zr, mapContent)
|
||||
zr.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -105,14 +105,12 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
||||
buf.Pos = 0
|
||||
buf.Data = data[offset:]
|
||||
|
||||
if zr, err = zlib.NewReader(&buf); err != nil {
|
||||
if err = zr.(zlib.Resetter).Reset(&buf, nil); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Discard the meta data.
|
||||
_, err = io.Copy(ioutil.Discard, zr)
|
||||
zr.Close()
|
||||
if err != nil {
|
||||
if _, err = io.Copy(ioutil.Discard, zr); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user