summaryrefslogtreecommitdiff
path: root/src/pkg/hash
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-11-06 14:24:38 -0800
committerRobert Griesemer <gri@golang.org>2009-11-06 14:24:38 -0800
commit5ea9dfbc5eaea67b5c0a762717ba9f7af0f4e6d5 (patch)
treefd7e0c9961bc3af2ddf105e9cc1943f2509ac584 /src/pkg/hash
parent581ffd7d5de85b3bfcae8918d538ecb1907f59db (diff)
downloadgo-5ea9dfbc5eaea67b5c0a762717ba9f7af0f4e6d5.tar.gz
- fine-tuning of one-line func heuristic (nodes.go)
- enabled for function declarations (not just function literals) - applied gofmt -w $GOROOT/src (look for instance at src/pkg/debug/elf/elf.go) R=r, rsc CC=go-dev http://go/go-review/1026006
Diffstat (limited to 'src/pkg/hash')
-rw-r--r--src/pkg/hash/adler32/adler32.go16
-rw-r--r--src/pkg/hash/crc32/crc32.go28
2 files changed, 11 insertions, 33 deletions
diff --git a/src/pkg/hash/adler32/adler32.go b/src/pkg/hash/adler32/adler32.go
index 2cd7a198a..3ac6364f9 100644
--- a/src/pkg/hash/adler32/adler32.go
+++ b/src/pkg/hash/adler32/adler32.go
@@ -30,9 +30,7 @@ type digest struct {
a, b uint32;
}
-func (d *digest) Reset() {
- d.a, d.b = 1, 0;
-}
+func (d *digest) Reset() { d.a, d.b = 1, 0 }
// New returns a new Hash32 computing the Adler-32 checksum.
func New() hash.Hash32 {
@@ -41,9 +39,7 @@ func New() hash.Hash32 {
return d;
}
-func (d *digest) Size() int {
- return Size;
-}
+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) {
@@ -76,9 +72,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
return len(p), nil;
}
-func (d *digest) Sum32() uint32 {
- return finish(d.a, d.b);
-}
+func (d *digest) Sum32() uint32 { return finish(d.a, d.b) }
func (d *digest) Sum() []byte {
p := make([]byte, 4);
@@ -91,6 +85,4 @@ func (d *digest) Sum() []byte {
}
// Checksum returns the Adler-32 checksum of data.
-func Checksum(data []byte) uint32 {
- return finish(update(1, 0, data));
-}
+func Checksum(data []byte) uint32 { return finish(update(1, 0, data)) }
diff --git a/src/pkg/hash/crc32/crc32.go b/src/pkg/hash/crc32/crc32.go
index 2f5fb8f89..e450f5fb7 100644
--- a/src/pkg/hash/crc32/crc32.go
+++ b/src/pkg/hash/crc32/crc32.go
@@ -62,23 +62,15 @@ type digest struct {
// New creates a new Hash computing the CRC-32 checksum
// using the polynomial represented by the Table.
-func New(tab *Table) hash.Hash32 {
- return &digest{0, tab};
-}
+func New(tab *Table) hash.Hash32 { return &digest{0, tab} }
// NewIEEE creates a new Hash computing the CRC-32 checksum
// using the IEEE polynomial.
-func NewIEEE() hash.Hash32 {
- return New(IEEETable);
-}
+func NewIEEE() hash.Hash32 { return New(IEEETable) }
-func (d *digest) Size() int {
- return Size;
-}
+func (d *digest) Size() int { return Size }
-func (d *digest) Reset() {
- d.crc = 0;
-}
+func (d *digest) Reset() { d.crc = 0 }
func update(crc uint32, tab *Table, p []byte) uint32 {
crc = ^crc;
@@ -93,9 +85,7 @@ func (d *digest) Write(p []byte) (n int, err os.Error) {
return len(p), nil;
}
-func (d *digest) Sum32() uint32 {
- return d.crc;
-}
+func (d *digest) Sum32() uint32 { return d.crc }
func (d *digest) Sum() []byte {
p := make([]byte, 4);
@@ -109,12 +99,8 @@ func (d *digest) Sum() []byte {
// Checksum returns the CRC-32 checksum of data
// using the polynomial represented by the Table.
-func Checksum(data []byte, tab *Table) uint32 {
- return update(0, tab, data);
-}
+func Checksum(data []byte, tab *Table) uint32 { return update(0, tab, data) }
// ChecksumIEEE returns the CRC-32 checksum of data
// using the IEEE polynomial.
-func ChecksumIEEE(data []byte) uint32 {
- return update(0, IEEETable, data);
-}
+func ChecksumIEEE(data []byte) uint32 { return update(0, IEEETable, data) }