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

Unified Diff: third_party/WebKit/Source/wtf/text/StringImpl.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/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/StringImpl.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.cpp b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
index bb0eaeb4b05b34f5917021c8bf8eb9fe616a3bd9..db0bd122af274fc91206ab3913c383f528c6e795 100644
--- a/third_party/WebKit/Source/wtf/text/StringImpl.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
@@ -973,6 +973,28 @@ PassRefPtr<StringImpl> StringImpl::removeCharacters(CharacterMatchFunctionPtr fi
return removeCharacters(characters16(), findMatch);
}
+PassRefPtr<StringImpl> StringImpl::remove(unsigned start, unsigned lengthToRemove)
+{
+ if (lengthToRemove <= 0)
+ return this;
+ if (start >= m_length)
+ return this;
+
+ lengthToRemove = std::min(m_length - start, lengthToRemove);
+ unsigned removedEnd = start + lengthToRemove;
+
+ if (is8Bit()) {
+ StringBuffer<LChar> buffer(m_length - lengthToRemove);
+ copyChars(buffer.characters(), characters8(), start);
+ copyChars(buffer.characters() + start, characters8() + removedEnd, m_length - removedEnd);
+ return buffer.release();
+ }
+ StringBuffer<UChar> buffer(m_length - lengthToRemove);
+ copyChars(buffer.characters(), characters16(), start);
+ copyChars(buffer.characters() + start, characters16() + removedEnd, m_length - removedEnd);
+ return buffer.release();
+}
+
template <typename CharType, class UCharPredicate>
inline PassRefPtr<StringImpl> StringImpl::simplifyMatchedCharactersToSpace(UCharPredicate predicate, StripBehavior stripBehavior)
{
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698