MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / XXH32_finalize

Function XXH32_finalize

ext/xxHash/src/include/xxhash.h:1994–2065  ·  view source on GitHub ↗

! * @internal * @brief Processes the last 0-15 bytes of @p ptr. * * There may be up to 15 bytes remaining to consume from the input. * This final stage will digest them to ensure that all input bytes are present * in the final mix. * * @param h32 The hash to finalize. * @param ptr The pointer to the remaining input. * @param len The remaining length, modulo 16. * @param align Whether @p

Source from the content-addressed store, hash-verified

1992 * @return The finalized hash.
1993 */
1994static xxh_u32
1995XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align)
1996{
1997#define XXH_PROCESS1 do { \
1998 h32 += (*ptr++) * XXH_PRIME32_5; \
1999 h32 = XXH_rotl32(h32, 11) * XXH_PRIME32_1; \
2000} while (0)
2001
2002#define XXH_PROCESS4 do { \
2003 h32 += XXH_get32bits(ptr) * XXH_PRIME32_3; \
2004 ptr += 4; \
2005 h32 = XXH_rotl32(h32, 17) * XXH_PRIME32_4; \
2006} while (0)
2007
2008 if (ptr==NULL) XXH_ASSERT(len == 0);
2009
2010 /* Compact rerolled version; generally faster */
2011 if (!XXH32_ENDJMP) {
2012 len &= 15;
2013 while (len >= 4) {
2014 XXH_PROCESS4;
2015 len -= 4;
2016 }
2017 while (len > 0) {
2018 XXH_PROCESS1;
2019 --len;
2020 }
2021 return XXH32_avalanche(h32);
2022 } else {
2023 switch(len&15) /* or switch(bEnd - p) */ {
2024 case 12: XXH_PROCESS4;
2025 XXH_FALLTHROUGH;
2026 case 8: XXH_PROCESS4;
2027 XXH_FALLTHROUGH;
2028 case 4: XXH_PROCESS4;
2029 return XXH32_avalanche(h32);
2030
2031 case 13: XXH_PROCESS4;
2032 XXH_FALLTHROUGH;
2033 case 9: XXH_PROCESS4;
2034 XXH_FALLTHROUGH;
2035 case 5: XXH_PROCESS4;
2036 XXH_PROCESS1;
2037 return XXH32_avalanche(h32);
2038
2039 case 14: XXH_PROCESS4;
2040 XXH_FALLTHROUGH;
2041 case 10: XXH_PROCESS4;
2042 XXH_FALLTHROUGH;
2043 case 6: XXH_PROCESS4;
2044 XXH_PROCESS1;
2045 XXH_PROCESS1;
2046 return XXH32_avalanche(h32);
2047
2048 case 15: XXH_PROCESS4;
2049 XXH_FALLTHROUGH;
2050 case 11: XXH_PROCESS4;
2051 XXH_FALLTHROUGH;

Callers 2

XXH32_endian_alignFunction · 0.85

Calls 1

XXH32_avalancheFunction · 0.85

Tested by

no test coverage detected