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