Title: [134677] trunk/Source/WTF
- Revision
- 134677
- Author
- msab...@apple.com
- Date
- 2012-11-14 15:04:43 -0800 (Wed, 14 Nov 2012)
Log Message
String::append() should handle two 8 bit strings without converting both to 16 bits
https://bugs.webkit.org/show_bug.cgi?id=102286
Reviewed by Oliver Hunt.
If both strings are 8 bit, then allocate and copy to a new 8 bit string. Since most strings are
8 bit, this will save up to 3x the resulting string length in bytes. 2x is due to the possible
surviving 16 bit source string upconversion and 1x for the 16 bit result now being 8 bit.
* wtf/text/WTFString.cpp:
(WTF::String::append):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (134676 => 134677)
--- trunk/Source/WTF/ChangeLog 2012-11-14 23:02:37 UTC (rev 134676)
+++ trunk/Source/WTF/ChangeLog 2012-11-14 23:04:43 UTC (rev 134677)
@@ -1,3 +1,17 @@
+2012-11-14 Michael Saboff <msab...@apple.com>
+
+ String::append() should handle two 8 bit strings without converting both to 16 bits
+ https://bugs.webkit.org/show_bug.cgi?id=102286
+
+ Reviewed by Oliver Hunt.
+
+ If both strings are 8 bit, then allocate and copy to a new 8 bit string. Since most strings are
+ 8 bit, this will save up to 3x the resulting string length in bytes. 2x is due to the possible
+ surviving 16 bit source string upconversion and 1x for the 16 bit result now being 8 bit.
+
+ * wtf/text/WTFString.cpp:
+ (WTF::String::append):
+
2012-11-14 Csaba Osztrogonác <o...@webkit.org>
[Qt][ARM] Enable the DFG JIT on ARMv7(Thumb2)
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (134676 => 134677)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2012-11-14 23:02:37 UTC (rev 134676)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2012-11-14 23:04:43 UTC (rev 134677)
@@ -103,6 +103,16 @@
// call to fastMalloc every single time.
if (str.m_impl) {
if (m_impl) {
+ if (m_impl->is8Bit() && str.m_impl->is8Bit()) {
+ LChar* data;
+ if (str.length() > numeric_limits<unsigned>::max() - m_impl->length())
+ CRASH();
+ RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + str.length(), data);
+ memcpy(data, m_impl->characters8(), m_impl->length() * sizeof(LChar));
+ memcpy(data + m_impl->length(), str.characters8(), str.length() * sizeof(LChar));
+ m_impl = newImpl.release();
+ return;
+ }
UChar* data;
if (str.length() > numeric_limits<unsigned>::max() - m_impl->length())
CRASH();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes