]> Cypherpunks repositories - gostls13.git/commit
hash/crc32: cleanup code and improve tests
authorRadu Berinde <radu@cockroachlabs.com>
Sun, 28 Aug 2016 18:36:06 +0000 (14:36 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 31 Aug 2016 15:17:57 +0000 (15:17 +0000)
commitbdde10137b3e67383f38329b02b329a906b78d5d
tree584e9768b0fe5bcdb88ff5987bb79e1c7c994a78
parent2a2cab2911083f1ed2ea5c6bf24a12e2c5f6bcfc
hash/crc32: cleanup code and improve tests

Major reorganization of the crc32 code:

 - The arch-specific files now implement a well-defined interface
   (documented in crc32.go). They no longer have the responsibility of
   initializing and falling back to a non-accelerated implementation;
   instead, that happens in the higher level code.

 - The non-accelerated algorithms are moved to a separate file with no
   dependencies on other code.

 - The "cutoff" optimization for slicing-by-8 is moved inside the
   algorithm itself (as opposed to every callsite).

Tests are significantly improved:
 - direct tests for the non-accelerated algorithms.
 - "cross-check" tests for arch-specific implementations (all archs).
 - tests for misaligned buffers for both IEEE and Castagnoli.

Fixes #16909.

Change-Id: I9b6dd83b7a57cd615eae901c0a6d61c6b8091c74
Reviewed-on: https://go-review.googlesource.com/27935
Reviewed-by: Keith Randall <khr@golang.org>
src/hash/crc32/crc32.go
src/hash/crc32/crc32_amd64.go
src/hash/crc32/crc32_amd64_test.go [deleted file]
src/hash/crc32/crc32_amd64p32.go
src/hash/crc32/crc32_generic.go
src/hash/crc32/crc32_otherarch.go [new file with mode: 0644]
src/hash/crc32/crc32_s390x.go
src/hash/crc32/crc32_test.go