summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/DJB.cpp
blob: c696f1e6a0bff043f63711e848ed4c42864eb704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//===-- Support/DJB.cpp ---DJB Hash -----------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains support for the DJ Bernstein hash function.
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/DJB.h"

uint32_t llvm::djbHash(StringRef Buffer, uint32_t H) {
  for (char C : Buffer.bytes())
    H = ((H << 5) + H) + C;
  return H;
}
OpenPOWER on IntegriCloud