Title: [119222] trunk/Source/WTF
Revision
119222
Author
[email protected]
Date
2012-06-01 05:52:27 -0700 (Fri, 01 Jun 2012)

Log Message

[Qt] Save one copy when going from 8-bit WTF::String to QString

Asking for characters() of an 8-bit string will make a 16-bit copy internally
in WTF::String. Since we're going to copy the data to QStringData anyways, which
is 16-bit, we can do the conversion ourselves and save one copy.

Reviewed by Simon Hausmann.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (119221 => 119222)


--- trunk/Source/WTF/ChangeLog	2012-06-01 12:50:38 UTC (rev 119221)
+++ trunk/Source/WTF/ChangeLog	2012-06-01 12:52:27 UTC (rev 119222)
@@ -1,3 +1,16 @@
+2012-06-01  Tor Arne Vestbø  <[email protected]>
+
+        [Qt] Save one copy when going from 8-bit WTF::String to QString
+
+        Asking for characters() of an 8-bit string will make a 16-bit copy internally
+        in WTF::String. Since we're going to copy the data to QStringData anyways, which
+        is 16-bit, we can do the conversion ourselves and save one copy.
+
+        Reviewed by Simon Hausmann.
+
+        * wtf/qt/StringQt.cpp:
+        (WTF::String::operator QString):
+
 2012-05-30  Tor Arne Vestbø  <[email protected]>
 
         [Qt] Make conversion from QString to WTF::String (and back again) ~free

Modified: trunk/Source/WTF/wtf/qt/StringQt.cpp (119221 => 119222)


--- trunk/Source/WTF/wtf/qt/StringQt.cpp	2012-06-01 12:50:38 UTC (rev 119221)
+++ trunk/Source/WTF/wtf/qt/StringQt.cpp	2012-06-01 12:52:27 UTC (rev 119222)
@@ -65,6 +65,12 @@
         return QString(qStringDataPointer);
     }
 #endif
+    if (is8Bit() && !m_impl->has16BitShadow()) {
+        // Asking for characters() of an 8-bit string will make a 16-bit copy internally
+        // in WTF::String. Since we're going to copy the data to QStringData anyways, we
+        // can do the conversion ourselves and save one copy.
+        return QString::fromLatin1(reinterpret_cast<const char*>(characters8()), length());
+    }
 
     return QString(reinterpret_cast<const QChar*>(characters()), length());
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to