blob: c696f1e6a0bff043f63711e848ed4c42864eb704 [file] [log] [blame]
Jonas Devlieghere92ac9d32018-01-28 11:05:10 +00001//===-- Support/DJB.cpp ---DJB Hash -----------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains support for the DJ Bernstein hash function.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Support/DJB.h"
15
16uint32_t llvm::djbHash(StringRef Buffer, uint32_t H) {
17 for (char C : Buffer.bytes())
Pavel Labath918f6002018-02-14 11:06:39 +000018 H = ((H << 5) + H) + C;
Jonas Devlieghere92ac9d32018-01-28 11:05:10 +000019 return H;
20}