1 //===-- llvm/ADT/Hashing.cpp - Utilities for hashing ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/Hashing.h"
14 // Add a possibly unaligned sequence of bytes.
15 void GeneralHash::addUnaligned(const uint8_t *I, const uint8_t *E) {
16 ptrdiff_t Length = E - I;
17 if ((uintptr_t(I) & 3) == 0) {
19 mix(*reinterpret_cast<const uint32_t *>(I));
27 (uint32_t(I[1]) << 8) +
28 (uint32_t(I[2]) << 16) +
29 (uint32_t(I[3]) << 24));
38 case 3: Data |= uint32_t(I[2]) << 16; // fall through
39 case 2: Data |= uint32_t(I[1]) << 8; // fall through
40 case 1: Data |= uint32_t(I[0]); break;