Title: [125958] trunk
Revision
125958
Author
[email protected]
Date
2012-08-17 17:43:25 -0700 (Fri, 17 Aug 2012)

Log Message

Add ability to create AtomicString using LChar* buffer and length
https://bugs.webkit.org/show_bug.cgi?id=94381

Reviewed by Geoffrey Garen.

Allows the use of 8 bit string data directly without converting to 16 bits first.

* wtf/text/AtomicString.cpp:
(WTF::LCharBufferTranslator::hash):
(LCharBufferTranslator):
(WTF::LCharBufferTranslator::equal):
(WTF::LCharBufferTranslator::translate):
(WTF::AtomicString::add):
* wtf/text/AtomicString.h:
(WTF::AtomicString::AtomicString):
(AtomicString):
* wtf/text/StringImpl.h:
(StringImpl):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (125957 => 125958)


--- trunk/Source/WTF/ChangeLog	2012-08-18 00:42:26 UTC (rev 125957)
+++ trunk/Source/WTF/ChangeLog	2012-08-18 00:43:25 UTC (rev 125958)
@@ -1,3 +1,24 @@
+2012-08-17  Michael Saboff  <[email protected]>
+
+        Add ability to create AtomicString using LChar* buffer and length
+        https://bugs.webkit.org/show_bug.cgi?id=94381
+
+        Reviewed by Geoffrey Garen.
+
+        Allows the use of 8 bit string data directly without converting to 16 bits first.
+
+        * wtf/text/AtomicString.cpp:
+        (WTF::LCharBufferTranslator::hash):
+        (LCharBufferTranslator):
+        (WTF::LCharBufferTranslator::equal):
+        (WTF::LCharBufferTranslator::translate):
+        (WTF::AtomicString::add):
+        * wtf/text/AtomicString.h:
+        (WTF::AtomicString::AtomicString):
+        (AtomicString):
+        * wtf/text/StringImpl.h:
+        (StringImpl):
+
 2012-08-17  Benjamin Poulain  <[email protected]>
 
         Make it easier to append a literal to StringBuilder

Modified: trunk/Source/WTF/wtf/text/AtomicString.cpp (125957 => 125958)


--- trunk/Source/WTF/wtf/text/AtomicString.cpp	2012-08-18 00:42:26 UTC (rev 125957)
+++ trunk/Source/WTF/wtf/text/AtomicString.cpp	2012-08-18 00:43:25 UTC (rev 125958)
@@ -298,7 +298,27 @@
     SubstringLocation buffer = { baseString, start, length };
     return addToStringTable<SubstringLocation, SubstringTranslator>(buffer);
 }
+    
+typedef HashTranslatorCharBuffer<LChar> LCharBuffer;
+struct LCharBufferTranslator {
+    static unsigned hash(const LCharBuffer& buf)
+    {
+        return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length);
+    }
 
+    static bool equal(StringImpl* const& str, const LCharBuffer& buf)
+    {
+        return WTF::equal(str, buf.s, buf.length);
+    }
+
+    static void translate(StringImpl*& location, const LCharBuffer& buf, unsigned hash)
+    {
+        location = StringImpl::create(buf.s, buf.length).leakRef();
+        location->setHash(hash);
+        location->setIsAtomic(true);
+    }
+};
+
 typedef HashTranslatorCharBuffer<char> CharBuffer;
 struct CharBufferFromLiteralDataTranslator {
     static unsigned hash(const CharBuffer& buf)
@@ -319,6 +339,18 @@
     }
 };
 
+PassRefPtr<StringImpl> AtomicString::add(const LChar* s, unsigned length)
+{
+    if (!s)
+        return 0;
+
+    if (!length)
+        return StringImpl::empty();
+
+    LCharBuffer buffer = { s, length };
+    return addToStringTable<LCharBuffer, LCharBufferTranslator>(buffer);
+}
+
 PassRefPtr<StringImpl> AtomicString::addFromLiteralData(const char* characters, unsigned length)
 {
     ASSERT(characters);

Modified: trunk/Source/WTF/wtf/text/AtomicString.h (125957 => 125958)


--- trunk/Source/WTF/wtf/text/AtomicString.h	2012-08-18 00:42:26 UTC (rev 125957)
+++ trunk/Source/WTF/wtf/text/AtomicString.h	2012-08-18 00:43:25 UTC (rev 125958)
@@ -43,6 +43,7 @@
     AtomicString() { }
     AtomicString(const LChar* s) : m_string(add(s)) { }
     AtomicString(const char* s) : m_string(add(s)) { }
+    AtomicString(const LChar* s, unsigned length) : m_string(add(s, length)) { }
     AtomicString(const UChar* s, unsigned length) : m_string(add(s, length)) { }
     AtomicString(const UChar* s, unsigned length, unsigned existingHash) : m_string(add(s, length, existingHash)) { }
     AtomicString(const UChar* s) : m_string(add(s)) { }
@@ -158,6 +159,7 @@
     
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> add(const LChar*);
     ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s) { return add(reinterpret_cast<const LChar*>(s)); };
+    WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> add(const LChar*, unsigned length);
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> add(const UChar*, unsigned length);
     ALWAYS_INLINE static PassRefPtr<StringImpl> add(const char* s, unsigned length) { return add(reinterpret_cast<const char*>(s), length); };
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned existingHash);

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (125957 => 125958)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2012-08-18 00:42:26 UTC (rev 125957)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2012-08-18 00:43:25 UTC (rev 125958)
@@ -58,6 +58,7 @@
 struct CStringTranslator;
 template<typename CharacterType> struct HashAndCharactersTranslator;
 struct HashAndUTF8CharactersTranslator;
+struct LCharBufferTranslator;
 struct CharBufferFromLiteralDataTranslator;
 struct SubstringTranslator;
 struct UCharBufferTranslator;
@@ -77,6 +78,7 @@
     template<typename CharacterType> friend struct WTF::HashAndCharactersTranslator;
     friend struct WTF::HashAndUTF8CharactersTranslator;
     friend struct WTF::CharBufferFromLiteralDataTranslator;
+    friend struct WTF::LCharBufferTranslator;
     friend struct WTF::SubstringTranslator;
     friend struct WTF::UCharBufferTranslator;
     friend class AtomicStringImpl;

Modified: trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme (125957 => 125958)


--- trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme	2012-08-18 00:42:26 UTC (rev 125957)
+++ trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme	2012-08-18 00:43:25 UTC (rev 125958)
@@ -118,13 +118,14 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
-      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
       buildConfiguration = "Debug"
       ignoresPersistentStateOnLaunch = "YES"
       debugDocumentVersioning = "YES"
+      enableOpenGLFrameCaptureMode = "0"
       allowLocationSimulation = "YES">
       <PathRunnable
          FilePath = "/Applications/Safari.app/Contents/MacOS/SafariForWebKitDevelopment">
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to