Title: [130404] trunk/Source/WTF
- Revision
- 130404
- Author
- msab...@apple.com
- Date
- 2012-10-04 09:45:28 -0700 (Thu, 04 Oct 2012)
Log Message
String::remove will convert an 8 bit string to a 16 bit string
https://bugs.webkit.org/show_bug.cgi?id=98299
Reviewed by Benjamin Poulain.
Added an 8 bit path to remove(). Added a private templated helper removeInternal.
* wtf/text/WTFString.cpp:
(WTF::String::removeInternal):
(WTF::String::remove):
* wtf/text/WTFString.h:
(String):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (130403 => 130404)
--- trunk/Source/WTF/ChangeLog 2012-10-04 16:39:46 UTC (rev 130403)
+++ trunk/Source/WTF/ChangeLog 2012-10-04 16:45:28 UTC (rev 130404)
@@ -1,3 +1,18 @@
+2012-10-04 Michael Saboff <msab...@apple.com>
+
+ String::remove will convert an 8 bit string to a 16 bit string
+ https://bugs.webkit.org/show_bug.cgi?id=98299
+
+ Reviewed by Benjamin Poulain.
+
+ Added an 8 bit path to remove(). Added a private templated helper removeInternal.
+
+ * wtf/text/WTFString.cpp:
+ (WTF::String::removeInternal):
+ (WTF::String::remove):
+ * wtf/text/WTFString.h:
+ (String):
+
2012-10-03 Kangil Han <kangil....@samsung.com>
[Refactoring] Tidy NDEBUG optioning in RefCountedBase.
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (130403 => 130404)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2012-10-04 16:39:46 UTC (rev 130403)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2012-10-04 16:45:28 UTC (rev 130404)
@@ -271,6 +271,18 @@
m_impl = newImpl.release();
}
+template <typename CharacterType>
+inline void String::removeInternal(const CharacterType* characters, unsigned position, int lengthToRemove)
+{
+ CharacterType* data;
+ RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data);
+ memcpy(data, characters, position * sizeof(CharacterType));
+ memcpy(data + position, characters + position + lengthToRemove,
+ (length() - lengthToRemove - position) * sizeof(CharacterType));
+
+ m_impl = newImpl.release();
+}
+
void String::remove(unsigned position, int lengthToRemove)
{
if (lengthToRemove <= 0)
@@ -279,12 +291,14 @@
return;
if (static_cast<unsigned>(lengthToRemove) > length() - position)
lengthToRemove = length() - position;
- UChar* data;
- RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data);
- memcpy(data, characters(), position * sizeof(UChar));
- memcpy(data + position, characters() + position + lengthToRemove,
- (length() - lengthToRemove - position) * sizeof(UChar));
- m_impl = newImpl.release();
+
+ if (is8Bit()) {
+ removeInternal(characters8(), position, lengthToRemove);
+
+ return;
+ }
+
+ removeInternal(characters16(), position, lengthToRemove);
}
String String::substring(unsigned pos, unsigned len) const
Modified: trunk/Source/WTF/wtf/text/WTFString.h (130403 => 130404)
--- trunk/Source/WTF/wtf/text/WTFString.h 2012-10-04 16:39:46 UTC (rev 130403)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2012-10-04 16:45:28 UTC (rev 130404)
@@ -459,6 +459,9 @@
}
private:
+ template <typename CharacterType>
+ void removeInternal(const CharacterType*, unsigned, int);
+
RefPtr<StringImpl> m_impl;
};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes