summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/wtf/text/StringBuilder.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/wtf/text/StringBuilder.h')
-rw-r--r--Source/JavaScriptCore/wtf/text/StringBuilder.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/wtf/text/StringBuilder.h b/Source/JavaScriptCore/wtf/text/StringBuilder.h
index f10af64..e891932 100644
--- a/Source/JavaScriptCore/wtf/text/StringBuilder.h
+++ b/Source/JavaScriptCore/wtf/text/StringBuilder.h
@@ -43,6 +43,9 @@ public:
void append(const String& string)
{
+ if (!string.length())
+ return;
+
// If we're appending to an empty string, and there is not buffer
// (in case reserveCapacity has been called) then just retain the
// string.
@@ -54,6 +57,22 @@ public:
append(string.characters(), string.length());
}
+ void append(const StringBuilder& other)
+ {
+ if (!other.m_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 && !other.m_string.isNull()) {
+ m_string = other.m_string;
+ m_length = other.m_length;
+ return;
+ }
+
+ append(other.characters(), other.m_length);
+ }
+
void append(const char* characters)
{
if (characters)
@@ -114,6 +133,16 @@ public:
return m_buffer->characters()[i];
}
+ const UChar* characters() const
+ {
+ if (!m_length)
+ return 0;
+ if (!m_string.isNull())
+ return m_string.characters();
+ ASSERT(m_buffer);
+ return m_buffer->characters();
+ }
+
void clear()
{
m_length = 0;