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

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

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.h
diff --git a/third_party/WebKit/Source/wtf/text/StringConcatenate.h b/third_party/WebKit/Source/wtf/text/StringConcatenate.h
index b9c6d948a08e6e23d2ef7e9f5f4fb1e90adab565..bbf254e29f34c13a82d62518fc8ea067119e3a21 100644
--- a/third_party/WebKit/Source/wtf/text/StringConcatenate.h
+++ b/third_party/WebKit/Source/wtf/text/StringConcatenate.h
@@ -264,44 +264,33 @@ private:
};
template<>
-class WTF_EXPORT StringTypeAdapter<String> {
+class WTF_EXPORT StringTypeAdapter<StringView> {
DISALLOW_NEW();
public:
- StringTypeAdapter<String>(const String& string)
- : m_buffer(string)
- {
- }
-
- unsigned length() { return m_buffer.length(); }
-
- bool is8Bit() { return m_buffer.isNull() || m_buffer.is8Bit(); }
+ StringTypeAdapter(const StringView& view)
+ : m_view(view) {}
+ unsigned length() { return m_view.length(); }
+ bool is8Bit() { return m_view.is8Bit(); }
void writeTo(LChar* destination);
-
void writeTo(UChar* destination);
private:
- const String& m_buffer;
+ const StringView m_view;
};
template<>
-class StringTypeAdapter<AtomicString> {
- DISALLOW_NEW();
+class StringTypeAdapter<String> : public StringTypeAdapter<StringView> {
public:
- StringTypeAdapter<AtomicString>(const AtomicString& string)
- : m_adapter(string.getString())
- {
- }
-
- unsigned length() { return m_adapter.length(); }
-
- bool is8Bit() { return m_adapter.is8Bit(); }
-
- void writeTo(LChar* destination) { m_adapter.writeTo(destination); }
- void writeTo(UChar* destination) { m_adapter.writeTo(destination); }
+ StringTypeAdapter(const String& string)
+ : StringTypeAdapter<StringView>(string) {}
+};
-private:
- StringTypeAdapter<String> m_adapter;
+template<>
+class StringTypeAdapter<AtomicString> : public StringTypeAdapter<StringView> {
+public:
+ StringTypeAdapter(const AtomicString& string)
+ : StringTypeAdapter<StringView>(string) {}
};
inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow)

Powered by Google App Engine
This is Rietveld 408576698