blob: cf8ea3a26e49475a9187d7005cc17b0f470609f6 [file] [log] [blame]
[email protected]5138d5f2011-05-07 00:49:341// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
[email protected]51ddf722012-09-01 00:55:095#ifndef BASE_HASH_H_
6#define BASE_HASH_H_
initial.commit586acc5fe2008-07-26 22:42:527
8#include <string>
9
[email protected]51ddf722012-09-01 00:55:0910#include "base/base_export.h"
initial.commit586acc5fe2008-07-26 22:42:5211#include "base/basictypes.h"
initial.commit586acc5fe2008-07-26 22:42:5212
[email protected]51ddf722012-09-01 00:55:0913namespace base {
initial.commit586acc5fe2008-07-26 22:42:5214
15// From http://www.azillionmonkeys.com/qed/hash.html
16// This is the hash used on WebCore/platform/stringhash
[email protected]51ddf722012-09-01 00:55:0917BASE_EXPORT uint32 SuperFastHash(const char * data, int len);
initial.commit586acc5fe2008-07-26 22:42:5218
19inline uint32 Hash(const char* key, size_t length) {
20 return SuperFastHash(key, static_cast<int>(length));
21}
22
23inline uint32 Hash(const std::string& key) {
24 if (key.empty())
25 return 0;
26 return SuperFastHash(key.data(), static_cast<int>(key.size()));
27}
28
[email protected]51ddf722012-09-01 00:55:0929} // namespace base
initial.commit586acc5fe2008-07-26 22:42:5230
[email protected]51ddf722012-09-01 00:55:0931#endif // BASE_HASH_H_