vendor: Temporarily patch github.com/chmduquesne/rollinghash

To avoid allocations in the hasher. PR files, should be available for
update soon.
This commit is contained in:
Jakob Borg 2017-01-18 18:45:29 +01:00
parent 68f1c6ccab
commit d4c4b1fb4c
1 changed files with 7 additions and 3 deletions

View File

@ -31,7 +31,7 @@ type digest struct {
func (d *digest) Reset() {
d.a = 1
d.b = 0
d.window = nil
d.window = d.window[:0]
d.oldest = 0
}
@ -55,9 +55,13 @@ func (d *digest) BlockSize() int { return 1 }
// Write (via the embedded io.Writer interface) adds more data to the
// running hash. It never returns an error.
func (d *digest) Write(p []byte) (int, error) {
// Copy the window
// Copy the window, avoiding allocations where possible
if len(d.window) != len(p) {
d.window = make([]byte, len(p))
if cap(d.window) >= len(p) {
d.window = d.window[:len(p)]
} else {
d.window = make([]byte, len(p))
}
}
copy(d.window, p)