crc32_generic.go 854 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2011 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build 386 arm arm64 ppc64 ppc64le appengine gccgo
  5. package crc32
  6. // The file contains the generic version of updateCastagnoli which does
  7. // slicing-by-8, or uses the fallback for very small sizes.
  8. func updateCastagnoli(crc uint32, p []byte) uint32 {
  9. // only use slicing-by-8 when input is >= 16 Bytes
  10. if len(p) >= 16 {
  11. return updateSlicingBy8(crc, castagnoliTable8, p)
  12. }
  13. return update(crc, castagnoliTable, p)
  14. }
  15. func updateIEEE(crc uint32, p []byte) uint32 {
  16. // only use slicing-by-8 when input is >= 16 Bytes
  17. if len(p) >= 16 {
  18. iEEETable8Once.Do(func() {
  19. iEEETable8 = makeTable8(IEEE)
  20. })
  21. return updateSlicingBy8(crc, iEEETable8, p)
  22. }
  23. return update(crc, IEEETable, p)
  24. }