mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Have lib/raczlib use lib/cgozlib
As the cmd/ractool comment changes say, this is almost a 2x speed-up for RAC+Zlib decoding on the enwik8 test file, comparable to the cgozlib benchmark numbers: $ go test -test.bench=. github.com/google/wuffs/lib/cgozlib goos: linux goarch: amd64 pkg: github.com/google/wuffs/lib/cgozlib BenchmarkCgo-56 2514 477230 ns/op BenchmarkPure-56 1090 1080853 ns/op
This commit is contained in:
1 parent
5125e51916
commit
fed2073b00
5 files changed
+104
-38
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// Copyright 2019 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package raczlib
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/google/wuffs/lib/cgozlib"
|
||||
"github.com/google/wuffs/lib/rac"
|
||||
)
|
||||
|
||||
// MakeDecompressor implements rac.CodecReader.
|
||||
func (r *CodecReader) MakeDecompressor(compressed io.Reader, rctx rac.ReaderContext) (io.Reader, error) {
|
||||
if r.cachedZlibReader == nil {
|
||||
r.cachedZlibReader = &cgozlib.Reader{}
|
||||
}
|
||||
if err := r.cachedZlibReader.Reset(compressed, rctx.Secondary); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.cachedZlibReader, nil
|
||||
}
|
||||
Reference in new issue
Block a user