aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/hash
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-05-20 00:18:15 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-05-20 00:18:15 +0000
commit9ff56c9570642711d5b7ab29920ecf5dbff14a27 (patch)
treec891bdec1e6f073f73fedeef23718bc3ac30d499 /libgo/go/hash
parent37cb25ed7acdb844b218231130e54b8b7a0ff6e6 (diff)
downloadgcc-9ff56c9570642711d5b7ab29920ecf5dbff14a27.zip
gcc-9ff56c9570642711d5b7ab29920ecf5dbff14a27.tar.gz
gcc-9ff56c9570642711d5b7ab29920ecf5dbff14a27.tar.bz2
Update to current version of Go library.
From-SVN: r173931
Diffstat (limited to 'libgo/go/hash')
-rw-r--r--libgo/go/hash/adler32/adler32.go6
-rw-r--r--libgo/go/hash/adler32/adler32_test.go14
-rw-r--r--libgo/go/hash/crc32/crc32.go5
-rw-r--r--libgo/go/hash/crc64/crc64.go5
-rw-r--r--libgo/go/hash/fnv/fnv.go5
-rw-r--r--libgo/go/hash/fnv/fnv_test.go2
-rw-r--r--libgo/go/hash/hash.go1
7 files changed, 27 insertions, 11 deletions
diff --git a/libgo/go/hash/adler32/adler32.go b/libgo/go/hash/adler32/adler32.go
index cd0c259..84943d9 100644
--- a/libgo/go/hash/adler32/adler32.go
+++ b/libgo/go/hash/adler32/adler32.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This package implements the Adler-32 checksum.
+// Package adler32 implements the Adler-32 checksum.
// Defined in RFC 1950:
// Adler-32 is composed of two sums accumulated per byte: s1 is
// the sum of all bytes, s2 is the sum of all s1 values. Both sums
@@ -43,8 +43,8 @@ func (d *digest) Size() int { return Size }
// Add p to the running checksum a, b.
func update(a, b uint32, p []byte) (aa, bb uint32) {
- for i := 0; i < len(p); i++ {
- a += uint32(p[i])
+ for _, pi := range p {
+ a += uint32(pi)
b += a
// invariant: a <= b
if b > (0xffffffff-255)/2 {
diff --git a/libgo/go/hash/adler32/adler32_test.go b/libgo/go/hash/adler32/adler32_test.go
index ffa5569..01f931c 100644
--- a/libgo/go/hash/adler32/adler32_test.go
+++ b/libgo/go/hash/adler32/adler32_test.go
@@ -5,6 +5,7 @@
package adler32
import (
+ "bytes"
"io"
"testing"
)
@@ -61,3 +62,16 @@ func TestGolden(t *testing.T) {
}
}
}
+
+func BenchmarkGolden(b *testing.B) {
+ b.StopTimer()
+ c := New()
+ var buf bytes.Buffer
+ for _, g := range golden {
+ buf.Write([]byte(g.in))
+ }
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ c.Write(buf.Bytes())
+ }
+}
diff --git a/libgo/go/hash/crc32/crc32.go b/libgo/go/hash/crc32/crc32.go
index 2ab0c54..88a4499 100644
--- a/libgo/go/hash/crc32/crc32.go
+++ b/libgo/go/hash/crc32/crc32.go
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This package implements the 32-bit cyclic redundancy check, or CRC-32, checksum.
-// See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for information.
+// Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32,
+// checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for
+// information.
package crc32
import (
diff --git a/libgo/go/hash/crc64/crc64.go b/libgo/go/hash/crc64/crc64.go
index 8443865..ae37e78 100644
--- a/libgo/go/hash/crc64/crc64.go
+++ b/libgo/go/hash/crc64/crc64.go
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This package implements the 64-bit cyclic redundancy check, or CRC-64, checksum.
-// See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for information.
+// Package crc64 implements the 64-bit cyclic redundancy check, or CRC-64,
+// checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for
+// information.
package crc64
import (
diff --git a/libgo/go/hash/fnv/fnv.go b/libgo/go/hash/fnv/fnv.go
index 66ab5a6..9a1c6a0 100644
--- a/libgo/go/hash/fnv/fnv.go
+++ b/libgo/go/hash/fnv/fnv.go
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The fnv package implements FNV-1 and FNV-1a,
-// non-cryptographic hash functions created by
-// Glenn Fowler, Landon Curt Noll, and Phong Vo.
+// Package fnv implements FNV-1 and FNV-1a, non-cryptographic hash functions
+// created by Glenn Fowler, Landon Curt Noll, and Phong Vo.
// See http://isthe.com/chongo/tech/comp/fnv/.
package fnv
diff --git a/libgo/go/hash/fnv/fnv_test.go b/libgo/go/hash/fnv/fnv_test.go
index 3ea3fe6..429230c 100644
--- a/libgo/go/hash/fnv/fnv_test.go
+++ b/libgo/go/hash/fnv/fnv_test.go
@@ -154,7 +154,7 @@ func benchmark(b *testing.B, h hash.Hash) {
b.ResetTimer()
b.SetBytes(testDataSize)
data := make([]byte, testDataSize)
- for i, _ := range data {
+ for i := range data {
data[i] = byte(i + 'a')
}
diff --git a/libgo/go/hash/hash.go b/libgo/go/hash/hash.go
index 56ac259..3536c0b 100644
--- a/libgo/go/hash/hash.go
+++ b/libgo/go/hash/hash.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Package hash provides interfaces for hash functions.
package hash
import "io"