summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/wtf/text/StringBuffer.h
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-07-31 05:58:08 +0000
committerabarth@chromium.org <abarth@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-07-31 05:58:08 +0000
commit0267e853faa33392b995197167a5d3c3d09dc5ed (patch)
tree90b6efb8e32d6d5314745b2bf924c161cf277ace /third_party/WebKit/Source/wtf/text/StringBuffer.h
parent42540cd653bcf90c532ce62accfb92e7dd94d01b (diff)
downloadchromium_src-0267e853faa33392b995197167a5d3c3d09dc5ed.zip
chromium_src-0267e853faa33392b995197167a5d3c3d09dc5ed.tar.gz
chromium_src-0267e853faa33392b995197167a5d3c3d09dc5ed.tar.bz2
Remove String::adopt(Vector<UChar>)
Adopting a Vector<UChar> isn't an efficient way to build a string. There are only two callers, so we should remove this API before we grow more. I've moved the callers over to StringBuilder and StringBuffer. There was one caller in EventSource that I moved to copying the characters rather than adopting them. R=eseidel Review URL: https://chromiumcodereview.appspot.com/21262003 git-svn-id: svn://svn.chromium.org/blink/trunk@155225 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/Source/wtf/text/StringBuffer.h')
-rw-r--r--third_party/WebKit/Source/wtf/text/StringBuffer.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/third_party/WebKit/Source/wtf/text/StringBuffer.h b/third_party/WebKit/Source/wtf/text/StringBuffer.h
index 3e3315d..2a9b356 100644
--- a/third_party/WebKit/Source/wtf/text/StringBuffer.h
+++ b/third_party/WebKit/Source/wtf/text/StringBuffer.h
@@ -40,6 +40,8 @@ template <typename CharType>
class StringBuffer {
WTF_MAKE_NONCOPYABLE(StringBuffer);
public:
+ StringBuffer() { }
+
explicit StringBuffer(unsigned length)
{
RELEASE_ASSERT(length <= std::numeric_limits<unsigned>::max() / sizeof(CharType));
@@ -60,8 +62,13 @@ public:
void resize(unsigned newLength)
{
+ RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / sizeof(CharType));
+ if (!m_data) {
+ CharType* characters;
+ m_data = StringImpl::createUninitialized(newLength, characters);
+ return;
+ }
if (newLength > m_data->length()) {
- RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / sizeof(UChar));
CharType* characters;
m_data = StringImpl::reallocate(m_data.release(), newLength, characters);
return;