Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Unified Diff: third_party/WebKit/Source/wtf/text/WTFString.cpp

Issue 2333933002: Move String::remove to StringImpl. (Closed)
Patch Set: types. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/WTFString.cpp
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.cpp b/third_party/WebKit/Source/wtf/text/WTFString.cpp
index 1686121ee24e005b6c8e6d665fa2ffea99ed07e2..a5662bdf9ff685861451add2be191b007dfd009a 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.cpp
+++ b/third_party/WebKit/Source/wtf/text/WTFString.cpp
@@ -248,34 +248,10 @@ void String::truncate(unsigned position)
}
}
-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)
+void String::remove(unsigned start, unsigned lengthToRemove)
{
- if (lengthToRemove <= 0)
- return;
- if (position >= length())
- return;
- if (static_cast<unsigned>(lengthToRemove) > length() - position)
- lengthToRemove = length() - position;
-
- if (is8Bit()) {
- removeInternal(characters8(), position, lengthToRemove);
-
- return;
- }
-
- removeInternal(characters16(), position, lengthToRemove);
+ if (m_impl)
+ m_impl = m_impl->remove(start, lengthToRemove);
}
String String::substring(unsigned pos, unsigned len) const
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698