Jonas Devlieghere | 92ac9d3 | 2018-01-28 11:05:10 +0000 | [diff] [blame] | 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()) |
Pavel Labath | 918f600 | 2018-02-14 11:06:39 +0000 | [diff] [blame] | 18 | H = ((H << 5) + H) + C; |
Jonas Devlieghere | 92ac9d3 | 2018-01-28 11:05:10 +0000 | [diff] [blame] | 19 | return H; |
| 20 | } |