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

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

Issue 2106283004: Allocate space in StringBuilder for m_string and the new bytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/StringBuilder.h
diff --git a/third_party/WebKit/Source/wtf/text/StringBuilder.h b/third_party/WebKit/Source/wtf/text/StringBuilder.h
index 783fdbaf8c8b4254a99af444239f488fd9c7ac13..70b986ea130a697af13b408a00a07a2521253b98 100644
--- a/third_party/WebKit/Source/wtf/text/StringBuilder.h
+++ b/third_party/WebKit/Source/wtf/text/StringBuilder.h
@@ -115,7 +115,7 @@ public:
append(static_cast<LChar>(c));
return;
}
- ensureBuffer16();
+ ensureBuffer16(1);
m_string = String();
m_buffer16->append(c);
++m_length;
@@ -127,7 +127,7 @@ public:
append(static_cast<UChar>(c));
return;
}
- ensureBuffer8();
+ ensureBuffer8(1);
m_string = String();
m_buffer8->append(c);
++m_length;
@@ -205,24 +205,27 @@ public:
void swap(StringBuilder&);
private:
- typedef Vector<LChar, 16> Buffer8;
- typedef Vector<UChar, 16> Buffer16;
+ static const unsigned kInlineBufferSize = 16;
+ static unsigned initialBufferSize() { return kInlineBufferSize; }
esprehn 2016/06/30 23:23:15 You have to have a method since using kInlineBuffe
- void ensureBuffer8()
+ typedef Vector<LChar, kInlineBufferSize> Buffer8;
+ typedef Vector<UChar, kInlineBufferSize> Buffer16;
+
+ void ensureBuffer8(unsigned addedSize)
{
DCHECK(m_is8Bit);
if (!hasBuffer())
- createBuffer8();
+ createBuffer8(addedSize);
}
- void ensureBuffer16()
+ void ensureBuffer16(unsigned addedSize)
{
if (m_is8Bit || !hasBuffer())
- createBuffer16();
+ createBuffer16(addedSize);
}
- void createBuffer8();
- void createBuffer16();
+ void createBuffer8(unsigned addedSize);
+ void createBuffer16(unsigned addedSize);
bool hasBuffer() const { return m_buffer; }

Powered by Google App Engine
This is Rietveld 408576698