summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/wtf/text
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/wtf/text')
-rw-r--r--Source/JavaScriptCore/wtf/text/AtomicString.cpp8
-rw-r--r--Source/JavaScriptCore/wtf/text/StringConcatenate.h28
-rw-r--r--Source/JavaScriptCore/wtf/text/StringHash.h4
-rw-r--r--Source/JavaScriptCore/wtf/text/StringImpl.h7
4 files changed, 36 insertions, 11 deletions
diff --git a/Source/JavaScriptCore/wtf/text/AtomicString.cpp b/Source/JavaScriptCore/wtf/text/AtomicString.cpp
index e0a866d..eb0dbbb 100644
--- a/Source/JavaScriptCore/wtf/text/AtomicString.cpp
+++ b/Source/JavaScriptCore/wtf/text/AtomicString.cpp
@@ -87,7 +87,7 @@ static inline PassRefPtr<StringImpl> addToStringTable(const T& value)
struct CStringTranslator {
static unsigned hash(const char* c)
{
- return StringImpl::computeHash(c);
+ return StringHasher::computeHash(c);
}
static bool equal(StringImpl* r, const char* s)
@@ -142,7 +142,7 @@ static inline bool equal(StringImpl* string, const UChar* characters, unsigned l
// FIXME: perhaps we should have a more abstract macro that indicates when
// going 4 bytes at a time is unsafe
-#if CPU(ARM) || CPU(SH4) || CPU(MIPS)
+#if CPU(ARM) || CPU(SH4) || CPU(MIPS) || CPU(SPARC)
const UChar* stringCharacters = string->characters();
for (unsigned i = 0; i != length; ++i) {
if (*stringCharacters++ != *characters++)
@@ -176,7 +176,7 @@ bool operator==(const AtomicString& string, const Vector<UChar>& vector)
struct UCharBufferTranslator {
static unsigned hash(const UCharBuffer& buf)
{
- return StringImpl::computeHash(buf.s, buf.length);
+ return StringHasher::computeHash(buf.s, buf.length);
}
static bool equal(StringImpl* const& str, const UCharBuffer& buf)
@@ -201,7 +201,7 @@ struct HashAndCharacters {
struct HashAndCharactersTranslator {
static unsigned hash(const HashAndCharacters& buffer)
{
- ASSERT(buffer.hash == StringImpl::computeHash(buffer.characters, buffer.length));
+ ASSERT(buffer.hash == StringHasher::computeHash(buffer.characters, buffer.length));
return buffer.hash;
}
diff --git a/Source/JavaScriptCore/wtf/text/StringConcatenate.h b/Source/JavaScriptCore/wtf/text/StringConcatenate.h
index 92a2d06..7fa7d2c 100644
--- a/Source/JavaScriptCore/wtf/text/StringConcatenate.h
+++ b/Source/JavaScriptCore/wtf/text/StringConcatenate.h
@@ -89,6 +89,34 @@ private:
};
template<>
+class StringTypeAdapter<const UChar*> {
+public:
+ StringTypeAdapter<const UChar*>(const UChar* buffer)
+ : m_buffer(buffer)
+ {
+ size_t len = 0;
+ while (m_buffer[len] != UChar(0))
+ len++;
+
+ if (len > std::numeric_limits<unsigned>::max())
+ CRASH();
+
+ m_length = len;
+ }
+
+ unsigned length() { return m_length; }
+
+ void writeTo(UChar* destination)
+ {
+ memcpy(destination, m_buffer, static_cast<size_t>(m_length) * sizeof(UChar));
+ }
+
+private:
+ const UChar* m_buffer;
+ unsigned m_length;
+};
+
+template<>
class StringTypeAdapter<const char*> {
public:
StringTypeAdapter<const char*>(const char* buffer)
diff --git a/Source/JavaScriptCore/wtf/text/StringHash.h b/Source/JavaScriptCore/wtf/text/StringHash.h
index d7aabdb..80193a6 100644
--- a/Source/JavaScriptCore/wtf/text/StringHash.h
+++ b/Source/JavaScriptCore/wtf/text/StringHash.h
@@ -104,7 +104,7 @@ namespace WTF {
static unsigned hash(const UChar* data, unsigned length)
{
- return StringHasher::createHash<UChar, foldCase<UChar> >(data, length);
+ return StringHasher::computeHash<UChar, foldCase<UChar> >(data, length);
}
static unsigned hash(StringImpl* str)
@@ -114,7 +114,7 @@ namespace WTF {
static unsigned hash(const char* data, unsigned length)
{
- return StringHasher::createHash<char, foldCase<char> >(data, length);
+ return StringHasher::computeHash<char, foldCase<char> >(data, length);
}
static bool equal(const StringImpl* a, const StringImpl* b)
diff --git a/Source/JavaScriptCore/wtf/text/StringImpl.h b/Source/JavaScriptCore/wtf/text/StringImpl.h
index a08427b..81911b3 100644
--- a/Source/JavaScriptCore/wtf/text/StringImpl.h
+++ b/Source/JavaScriptCore/wtf/text/StringImpl.h
@@ -136,7 +136,7 @@ private:
{
ASSERT(!isStatic());
ASSERT(!m_hash);
- ASSERT(hash == computeHash(m_data, m_length));
+ ASSERT(hash == StringHasher::computeHash(m_data, m_length));
m_hash = hash;
}
@@ -235,11 +235,8 @@ public:
m_refCountAndFlags &= ~s_refCountFlagIsAtomic;
}
- unsigned hash() const { if (!m_hash) m_hash = computeHash(m_data, m_length); return m_hash; }
+ unsigned hash() const { if (!m_hash) m_hash = StringHasher::computeHash(m_data, m_length); return m_hash; }
unsigned existingHash() const { ASSERT(m_hash); return m_hash; }
- static unsigned computeHash(const UChar* data, unsigned length) { return WTF::StringHasher::createHash<UChar>(data, length); }
- static unsigned computeHash(const char* data, unsigned length) { return WTF::StringHasher::createHash<char>(data, length); }
- static unsigned computeHash(const char* data) { return WTF::StringHasher::createHash<char>(data); }
ALWAYS_INLINE void deref() { m_refCountAndFlags -= s_refCountIncrement; if (!(m_refCountAndFlags & (s_refCountMask | s_refCountFlagStatic))) delete this; }
ALWAYS_INLINE bool hasOneRef() const { return (m_refCountAndFlags & (s_refCountMask | s_refCountFlagStatic)) == s_refCountIncrement; }