diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-01 00:55:09 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-01 00:55:09 +0000 |
commit | 51ddf72550374b626eb2ea3239ca13f04c8eb2b7 (patch) | |
tree | d9f20bad2e99049d57c3d9350cd5a6ce72952cff /base/hash.h | |
parent | 5731e121244fb91b97b37daefc1b59b27387b050 (diff) | |
download | chromium_src-51ddf72550374b626eb2ea3239ca13f04c8eb2b7.zip chromium_src-51ddf72550374b626eb2ea3239ca13f04c8eb2b7.tar.gz chromium_src-51ddf72550374b626eb2ea3239ca13f04c8eb2b7.tar.bz2 |
Move hash.h/cc from net to base.
Review URL: https://chromiumcodereview.appspot.com/10920026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154554 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/hash.h')
-rw-r--r-- | base/hash.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/base/hash.h b/base/hash.h new file mode 100644 index 0000000..cf8ea3a --- /dev/null +++ b/base/hash.h @@ -0,0 +1,31 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_HASH_H_ +#define BASE_HASH_H_ + +#include <string> + +#include "base/base_export.h" +#include "base/basictypes.h" + +namespace base { + +// From http://www.azillionmonkeys.com/qed/hash.html +// This is the hash used on WebCore/platform/stringhash +BASE_EXPORT uint32 SuperFastHash(const char * data, int len); + +inline uint32 Hash(const char* key, size_t length) { + return SuperFastHash(key, static_cast<int>(length)); +} + +inline uint32 Hash(const std::string& key) { + if (key.empty()) + return 0; + return SuperFastHash(key.data(), static_cast<int>(key.size())); +} + +} // namespace base + +#endif // BASE_HASH_H_ |