Chromium Code Reviews| 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 BASE_HASH_H__ |
|
rvargas (doing something else)
2012/08/31 23:06:08
nit: only one trailing undercore
jbates
2012/08/31 23:10:41
Done.
| |
| 6 #define NET_DISK_CACHE_HASH_H__ | 6 #define BASE_HASH_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "net/base/net_export.h" | |
| 12 | 12 |
| 13 namespace disk_cache { | 13 namespace base { |
| 14 | 14 |
| 15 // From http://www.azillionmonkeys.com/qed/hash.html | 15 // From http://www.azillionmonkeys.com/qed/hash.html |
| 16 // This is the hash used on WebCore/platform/stringhash | 16 // This is the hash used on WebCore/platform/stringhash |
| 17 NET_EXPORT_PRIVATE uint32 SuperFastHash(const char * data, int len); | 17 BASE_EXPORT_PRIVATE uint32 SuperFastHash(const char * data, int len); |
|
rvargas (doing something else)
2012/08/31 23:06:08
nit: Should not be private
jbates
2012/08/31 23:10:41
Done.
| |
| 18 | 18 |
| 19 inline uint32 Hash(const char* key, size_t length) { | 19 inline uint32 Hash(const char* key, size_t length) { |
| 20 return SuperFastHash(key, static_cast<int>(length)); | 20 return SuperFastHash(key, static_cast<int>(length)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 inline uint32 Hash(const std::string& key) { | 23 inline uint32 Hash(const std::string& key) { |
| 24 if (key.empty()) | 24 if (key.empty()) |
| 25 return 0; | 25 return 0; |
| 26 return SuperFastHash(key.data(), static_cast<int>(key.size())); | 26 return SuperFastHash(key.data(), static_cast<int>(key.size())); |
| 27 } | 27 } |
| 28 | 28 |
| 29 } // namespace disk_cache | 29 } // namespace disk_cache |
| 30 | 30 |
| 31 #endif // NET_DISK_CACHE_HASH_H__ | 31 #endif // NET_DISK_CACHE_HASH_H__ |
| OLD | NEW |