]> Cypherpunks repositories - gostls13.git/commit
hash/maphash: add Bytes and String
authorRuss Cox <rsc@golang.org>
Mon, 14 Mar 2022 16:31:33 +0000 (12:31 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 5 Apr 2022 18:01:26 +0000 (18:01 +0000)
commit9e16cc1541d42cb081d359339e3f45b4b9b2a372
tree469eeb85ad0f949b3bc46d91a807f675b9042b37
parent9839668b5619f45e293dd40339bf0ac614ea6bee
hash/maphash: add Bytes and String

For very small inputs, h.Reset+h.Write+h.Sum64 is fundamentally
slower than a single operation, by about a factor of two, because
Write must copy the data into h's buffer, just in case there is another
Write before the Sum64.

A single function doing the whole sequence knows there is no extra
write that will happen, so it doesn't need the buffer, so it avoids the copy.

Fixes #42710.

Change-Id: Icc79c68ccb10827f6640071d026df86b4940fcc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/392494
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
api/next/42710.txt [new file with mode: 0644]
src/hash/maphash/maphash.go
src/hash/maphash/maphash_test.go