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

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

Issue 2025503002: Revert of Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/Forward.h ('k') | third_party/WebKit/Source/wtf/text/StringView.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/StringBuilder.h
diff --git a/third_party/WebKit/Source/wtf/text/StringBuilder.h b/third_party/WebKit/Source/wtf/text/StringBuilder.h
index 527efaea5ffc88f308e2ac323090b805875e4d97..73cc2655e83cf11ef4f42de10b749a4c8ea74ab4 100644
--- a/third_party/WebKit/Source/wtf/text/StringBuilder.h
+++ b/third_party/WebKit/Source/wtf/text/StringBuilder.h
@@ -29,7 +29,6 @@
#include "wtf/WTFExport.h"
#include "wtf/text/AtomicString.h"
-#include "wtf/text/StringView.h"
#include "wtf/text/WTFString.h"
namespace WTF {
@@ -51,6 +50,26 @@
ALWAYS_INLINE void append(const char* characters, unsigned length) { append(reinterpret_cast<const LChar*>(characters), length); }
+ void append(const String& string)
+ {
+ if (!string.length())
+ return;
+
+ // If we're appending to an empty string, and there is not a buffer (reserveCapacity has not been called)
+ // then just retain the string.
+ if (!m_length && !m_buffer) {
+ m_string = string;
+ m_length = string.length();
+ m_is8Bit = m_string.is8Bit();
+ return;
+ }
+
+ if (string.is8Bit())
+ append(string.characters8(), string.length());
+ else
+ append(string.characters16(), string.length());
+ }
+
void append(const StringBuilder& other)
{
if (!other.m_length)
@@ -70,9 +89,7 @@
append(other.characters16(), other.m_length);
}
- // TODO(esprehn): This method is just duplicating what StringView itself
- // does. Remove it and replace callers with append(StringView(string, offset, length)).
- void append(const StringView& string, unsigned offset, unsigned length)
+ void append(const String& string, unsigned offset, unsigned length)
{
if (!string.length())
return;
@@ -96,6 +113,12 @@
append(string.characters8(), string.length());
else
append(string.characters16(), string.length());
+ }
+
+ void append(const char* characters)
+ {
+ if (characters)
+ append(characters, strlen(characters));
}
void append(UChar c)
« no previous file with comments | « third_party/WebKit/Source/wtf/Forward.h ('k') | third_party/WebKit/Source/wtf/text/StringView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698