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

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

Issue 2337683002: Move String::truncate to StringImpl. (Closed)
Patch Set: rebase 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 88db2e88d5c29426a50c017e923cc4544da45a7b..af7f739e13cb37f65d496b07db13f30c7c998789 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.cpp
+++ b/third_party/WebKit/Source/wtf/text/WTFString.cpp
@@ -231,21 +231,10 @@ void String::ensure16Bit()
m_impl = StringImpl::empty16Bit();
}
-void String::truncate(unsigned position)
+void String::truncate(unsigned length)
{
- if (position >= length())
- return;
- if (m_impl->is8Bit()) {
- LChar* data;
- RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(position, data);
- memcpy(data, m_impl->characters8(), position * sizeof(LChar));
- m_impl = newImpl.release();
- } else {
- UChar* data;
- RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(position, data);
- memcpy(data, m_impl->characters16(), position * sizeof(UChar));
- m_impl = newImpl.release();
- }
+ if (m_impl)
+ m_impl = m_impl->truncate(length);
}
void String::remove(unsigned start, unsigned lengthToRemove)
« 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