github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/klauspost/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 !amd64,!amd64p32 appengine gccgo
     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  	// only use slicing-by-8 when input is >= 16 Bytes
    14  	if len(p) >= 16 {
    15  		return updateSlicingBy8(crc, castagnoliTable8, p)
    16  	}
    17  	return update(crc, castagnoliTable, p)
    18  }
    19  
    20  func updateIEEE(crc uint32, p []byte) uint32 {
    21  	// only use slicing-by-8 when input is >= 16 Bytes
    22  	if len(p) >= 16 {
    23  		ieeeTable8Once.Do(func() {
    24  			ieeeTable8 = makeTable8(IEEE)
    25  		})
    26  		return updateSlicingBy8(crc, ieeeTable8, p)
    27  	}
    28  	return update(crc, IEEETable, p)
    29  }