1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#include "StringUtils.h" 7 8 9// from the Dragon Book: a slightly modified hashpjw() 10/*static*/ uint32 11StringUtils::HashValue(const char* string) 12{ 13 if (string == NULL) 14 return 0; 15 16 uint32 h = 0; 17 18 for (; *string; string++) { 19 uint32 g = h & 0xf0000000; 20 if (g) 21 h ^= g >> 24; 22 h = (h << 4) + *string; 23 } 24 25 return h; 26} 27