1 //===-- 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 
16 uint32_t llvm::djbHash(StringRef Buffer, uint32_t H) {
17   for (char C : Buffer.bytes())
18     H = ((H << 5) + H) + C;
19   return H;
20 }
21