vendor: Update golang.org/cznic/...

This commit is contained in:
Jakob Borg
2016-09-13 21:49:35 +02:00
parent 9bf6917ae8
commit 58cbd19742
31 changed files with 1104 additions and 8369 deletions

View File

@@ -10,6 +10,10 @@
package zappy
import (
"github.com/cznic/internal/buffer"
)
/*
#include <stdint.h>
@@ -109,7 +113,7 @@ func Decode(buf, src []byte) ([]byte, error) {
}
if len(buf) < dLen {
buf = make([]byte, dLen)
buf = *buffer.Get(dLen)
}
d := int(C.decode(C.int(s), C.int(len(src)), (*C.uint8_t)(&src[0]), C.int(len(buf)), (*C.uint8_t)(&buf[0])))

View File

@@ -12,6 +12,8 @@ package zappy
import (
"encoding/binary"
"github.com/cznic/internal/buffer"
)
func puregoDecode() bool { return true }
@@ -35,7 +37,7 @@ func Decode(buf, src []byte) ([]byte, error) {
}
if len(buf) < dLen {
buf = make([]byte, dLen)
buf = *buffer.Get(dLen)
}
var d, offset, length int

View File

@@ -33,5 +33,5 @@ func emitLiteral(dst, lit []byte) (n int) {
// MaxEncodedLen returns the maximum length of a zappy block, given its
// uncompressed length.
func MaxEncodedLen(srcLen int) int {
return 10 + srcLen
return 10 + srcLen + (srcLen+1)/2
}

View File

@@ -107,6 +107,8 @@ import (
"encoding/binary"
"fmt"
"math"
"github.com/cznic/internal/buffer"
)
func puregoEncode() bool { return false }
@@ -117,7 +119,7 @@ func puregoEncode() bool { return false }
// It is valid to pass a nil buf.
func Encode(buf, src []byte) ([]byte, error) {
if n := MaxEncodedLen(len(src)); len(buf) < n {
buf = make([]byte, n)
buf = *buffer.Get(n)
}
if len(src) > math.MaxInt32 {

View File

@@ -14,6 +14,8 @@ import (
"encoding/binary"
"fmt"
"math"
"github.com/cznic/internal/buffer"
)
func puregoEncode() bool { return true }
@@ -24,7 +26,7 @@ func puregoEncode() bool { return true }
// It is valid to pass a nil buf.
func Encode(buf, src []byte) ([]byte, error) {
if n := MaxEncodedLen(len(src)); len(buf) < n {
buf = make([]byte, n)
buf = *buffer.Get(n)
}
if len(src) > math.MaxInt32 {

View File

@@ -124,7 +124,6 @@ Old=Go snappy, new=zappy:
The package builds with CGO_ENABLED=0 as well, but the performance is worse.
$ CGO_ENABLED=0 go test -test.run=NONE -test.bench=. > old.benchcmp
$ CGO_ENABLED=1 go test -test.run=NONE -test.bench=. > new.benchcmp
$ benchcmp old.benchcmp new.benchcmp