summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/text/StringHash.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WTF/wtf/text/StringHash.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WTF/wtf/text/StringHash.h')
-rw-r--r--Source/WTF/wtf/text/StringHash.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/Source/WTF/wtf/text/StringHash.h b/Source/WTF/wtf/text/StringHash.h
index 88bdd9369..139b5169e 100644
--- a/Source/WTF/wtf/text/StringHash.h
+++ b/Source/WTF/wtf/text/StringHash.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2012, 2013 Apple Inc. All rights reserved
+ * Copyright (C) 2006-2008, 2012-2013, 2016 Apple Inc. All rights reserved
* Copyright (C) Research In Motion Limited 2009. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
#include <wtf/text/AtomicString.h>
#include <wtf/HashTraits.h>
-#include <wtf/StringHasher.h>
+#include <wtf/Hasher.h>
namespace WTF {
@@ -33,7 +33,15 @@ namespace WTF {
return value.isNull();
}
- // The hash() functions on StringHash and CaseFoldingHash do not support
+ inline void HashTraits<String>::customDeleteBucket(String& value)
+ {
+ // See unique_ptr's customDeleteBucket() for an explanation.
+ ASSERT(!isDeletedValue(value));
+ String valueToBeDestroyed = WTFMove(value);
+ constructDeletedValue(value);
+ }
+
+ // The hash() functions on StringHash and ASCIICaseInsensitiveHash do not support
// null strings. get(), contains(), and add() on HashMap<String,..., StringHash>
// cause a null-pointer dereference when passed null strings.
@@ -45,7 +53,7 @@ namespace WTF {
static unsigned hash(StringImpl* key) { return key->hash(); }
static inline bool equal(const StringImpl* a, const StringImpl* b)
{
- return equalNonNull(a, b);
+ return WTF::equal(*a, *b);
}
static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); }
@@ -71,14 +79,11 @@ namespace WTF {
static const bool safeToCompareToEmptyOrDeleted = false;
};
- class CaseFoldingHash {
+ class ASCIICaseInsensitiveHash {
public:
template<typename T> static inline UChar foldCase(T character)
{
- if (std::is_same<T, LChar>::value)
- return StringImpl::latin1CaseFoldTable[character];
-
- return u_foldCase(character, U_FOLD_CASE_DEFAULT);
+ return toASCIILower(character);
}
static unsigned hash(const UChar* data, unsigned length)
@@ -105,17 +110,23 @@ namespace WTF {
static inline unsigned hash(const char* data, unsigned length)
{
- return CaseFoldingHash::hash(reinterpret_cast<const LChar*>(data), length);
+ return hash(reinterpret_cast<const LChar*>(data), length);
}
+ static inline bool equal(const StringImpl& a, const StringImpl& b)
+ {
+ return equalIgnoringASCIICase(a, b);
+ }
static inline bool equal(const StringImpl* a, const StringImpl* b)
{
- return equalIgnoringCaseNonNull(a, b);
+ ASSERT(a);
+ ASSERT(b);
+ return equal(*a, *b);
}
static unsigned hash(const RefPtr<StringImpl>& key)
{
- return hash(*key);
+ return hash(key.get());
}
static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b)
@@ -167,8 +178,8 @@ namespace WTF {
}
+using WTF::ASCIICaseInsensitiveHash;
using WTF::AlreadyHashed;
-using WTF::CaseFoldingHash;
using WTF::StringHash;
#endif