1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_DISK_CACHE_HASH_H__ 6 #define NET_DISK_CACHE_HASH_H__ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 12 namespace disk_cache { 13 14 // From http://www.azillionmonkeys.com/qed/hash.html 15 // This is the hash used on WebCore/platform/stringhash 16 uint32 SuperFastHash(const char * data, int len); 17 Hash(const char * key,size_t length)18inline uint32 Hash(const char* key, size_t length) { 19 return SuperFastHash(key, static_cast<int>(length)); 20 } 21 Hash(const std::string & key)22inline uint32 Hash(const std::string& key) { 23 if (key.empty()) 24 return 0; 25 return SuperFastHash(key.data(), static_cast<int>(key.size())); 26 } 27 28 } // namespace disk_cache 29 30 #endif // NET_DISK_CACHE_HASH_H__ 31