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

Unified Diff: Source/wtf/text/StringBuffer.h

Issue 21262003: Remove String::adopt(Vector<UChar>) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo Created 7 years, 5 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 | « Source/core/platform/text/win/LocaleWin.cpp ('k') | Source/wtf/text/StringImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/StringBuffer.h
diff --git a/Source/wtf/text/StringBuffer.h b/Source/wtf/text/StringBuffer.h
index 3e3315d01c35b48a84a98434a206b7c10d9ab89f..2a9b356ecc22cee7eeb9a52c50cf352e6e65274a 100644
--- a/Source/wtf/text/StringBuffer.h
+++ b/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;
« no previous file with comments | « Source/core/platform/text/win/LocaleWin.cpp ('k') | Source/wtf/text/StringImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698