From 44f6c2e4a20176f15adaddc1ec7d806c8bfed19b Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 23 Mar 2013 10:10:15 +1100 Subject: [PATCH] go.crypto/sha3: fix typo; remove 4 million map lookups (5% of "go test" time); delete some comments that didn't add much and were incorrect anyway (the test specification was tc, not t). R=jcb CC=agl, golang-dev https://golang.org/cl/7665045 --- sha3/sha3_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sha3/sha3_test.go b/sha3/sha3_test.go index bad4076..67dd259 100644 --- a/sha3/sha3_test.go +++ b/sha3/sha3_test.go @@ -86,7 +86,7 @@ var shortKeccakTestVectors = []testVector{ // ExtremelyLongMsgKAT taken from http://keccak.noekeon.org/. var longKeccakTestVectors = []testVector{ { - desc: "long-1GiB", + desc: "long-64MiB", input: []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"), repeat: 1024 * 1024, want: map[string]string{ @@ -106,13 +106,12 @@ func TestKeccakVectors(t *testing.T) { } for _, tc := range testCases { for alg, want := range tc.want { - testDigests[alg].Reset() - // Write input data each digests, based on the test specification t. + d := testDigests[alg] + d.Reset() for i := 0; i < tc.repeat; i++ { - testDigests[alg].Write(tc.input) + d.Write(tc.input) } - // Verify that each algorithm version produced the expected output. - got := strings.ToUpper(hex.EncodeToString(testDigests[alg].Sum(nil))) + got := strings.ToUpper(hex.EncodeToString(d.Sum(nil))) if got != want { t.Errorf("%s, alg=%s\ngot %q, want %q", tc.desc, alg, got, want) }