diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
commit | 3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch) | |
tree | 73dc228333948738bbe02976cacca8cd382bc978 /Source/JavaScriptCore/runtime/Identifier.cpp | |
parent | b32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff) | |
download | qtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz |
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/JavaScriptCore/runtime/Identifier.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/Identifier.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Source/JavaScriptCore/runtime/Identifier.cpp b/Source/JavaScriptCore/runtime/Identifier.cpp index 20770928c..0fc54f3c6 100644 --- a/Source/JavaScriptCore/runtime/Identifier.cpp +++ b/Source/JavaScriptCore/runtime/Identifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -46,10 +46,10 @@ void deleteIdentifierTable(IdentifierTable* table) delete table; } -struct IdentifierCStringTranslator { +struct IdentifierASCIIStringTranslator { static unsigned hash(const LChar* c) { - return StringHasher::computeHash<LChar>(c); + return StringHasher::computeHashAndMaskTop8Bits<LChar>(c); } static bool equal(StringImpl* r, const LChar* s) @@ -60,19 +60,15 @@ struct IdentifierCStringTranslator { static void translate(StringImpl*& location, const LChar* c, unsigned hash) { size_t length = strlen(reinterpret_cast<const char*>(c)); - LChar* d; - StringImpl* r = StringImpl::createUninitialized(length, d).leakRef(); - for (size_t i = 0; i != length; i++) - d[i] = c[i]; - r->setHash(hash); - location = r; + location = StringImpl::createFromLiteral(reinterpret_cast<const char*>(c), length).leakRef(); + location->setHash(hash); } }; struct IdentifierLCharFromUCharTranslator { static unsigned hash(const CharBuffer<UChar>& buf) { - return StringHasher::computeHash<UChar>(buf.s, buf.length); + return StringHasher::computeHashAndMaskTop8Bits<UChar>(buf.s, buf.length); } static bool equal(StringImpl* str, const CharBuffer<UChar>& buf) @@ -96,10 +92,8 @@ struct IdentifierLCharFromUCharTranslator { PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const char* c) { - if (!c) - return 0; - if (!c[0]) - return StringImpl::empty(); + ASSERT(c); + ASSERT(c[0]); if (!c[1]) return add(globalData, globalData->smallStrings.singleCharacterStringRep(c[0])); @@ -110,7 +104,7 @@ PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const char* c) if (iter != literalIdentifierTable.end()) return iter->second; - HashSet<StringImpl*>::AddResult addResult = identifierTable.add<const LChar*, IdentifierCStringTranslator>(reinterpret_cast<const LChar*>(c)); + HashSet<StringImpl*>::AddResult addResult = identifierTable.add<const LChar*, IdentifierASCIIStringTranslator>(reinterpret_cast<const LChar*>(c)); // If the string is newly-translated, then we need to adopt it. // The boolean in the pair tells us if that is so. |