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

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

Issue 2359663002: wtf: Implement StringView specialization of string concatenation. (Closed)
Patch Set: StringImpl::copyChars 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
Index: third_party/WebKit/Source/wtf/text/StringConcatenate.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringConcatenate.cpp b/third_party/WebKit/Source/wtf/text/StringConcatenate.cpp
index 7da90e9cabd9f540cf1519e785f19c5f8f8344ce..3f7261644db6a7ee0f42b820772200f9bda3684c 100644
--- a/third_party/WebKit/Source/wtf/text/StringConcatenate.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringConcatenate.cpp
@@ -118,32 +118,18 @@ void WTF::StringTypeAdapter<Vector<LChar>>::writeTo(UChar* destination)
destination[i] = m_buffer[i];
}
-void WTF::StringTypeAdapter<String>::writeTo(LChar* destination)
+void WTF::StringTypeAdapter<StringView>::writeTo(LChar* destination)
{
- unsigned length = m_buffer.length();
-
- ASSERT(is8Bit());
- const LChar* data = m_buffer.characters8();
- for (unsigned i = 0; i < length; ++i)
- destination[i] = data[i];
-
+ DCHECK(is8Bit());
+ StringImpl::copyChars(destination, m_view.characters8(), m_view.length());
WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING();
}
-void WTF::StringTypeAdapter<String>::writeTo(UChar* destination)
+void WTF::StringTypeAdapter<StringView>::writeTo(UChar* destination)
{
- unsigned length = m_buffer.length();
-
- if (is8Bit()) {
- const LChar* data = m_buffer.characters8();
- for (unsigned i = 0; i < length; ++i)
- destination[i] = data[i];
- } else {
- const UChar* data = m_buffer.characters16();
- for (unsigned i = 0; i < length; ++i)
- destination[i] = data[i];
- }
-
+ if (is8Bit())
+ StringImpl::copyChars(destination, m_view.characters8(), m_view.length());
+ else
+ StringImpl::copyChars(destination, m_view.characters16(), m_view.length());
WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING();
}
-
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringConcatenate.h ('k') | third_party/WebKit/Source/wtf/text/StringOperators.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698