github.com/miolini/go@v0.0.0-20160405192216-fca68c8cb408/src/hash/crc32/crc32_generic.go (about)

     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  
     5  // +build 386 arm arm64 mips64 mips64le ppc64 ppc64le
     6  
     7  package crc32
     8  
     9  // This file contains the generic version of updateCastagnoli which does
    10  // slicing-by-8, or uses the fallback for very small sizes.
    11  
    12  func updateCastagnoli(crc uint32, p []byte) uint32 {
    13  	// Use slicing-by-8 on larger inputs.
    14  	if len(p) >= sliceBy8Cutoff {
    15  		return updateSlicingBy8(crc, castagnoliTable8, p)
    16  	}
    17  	return update(crc, castagnoliTable, p)
    18  }
    19  
    20  func updateIEEE(crc uint32, p []byte) uint32 {
    21  	// Use slicing-by-8 on larger inputs.
    22  	if len(p) >= sliceBy8Cutoff {
    23  		ieeeTable8Once.Do(func() {
    24  			ieeeTable8 = makeTable8(IEEE)
    25  		})
    26  		return updateSlicingBy8(crc, ieeeTable8, p)
    27  	}
    28  	return update(crc, IEEETable, p)
    29  }