| Index: Source/wtf/text/StringImpl.h
|
| diff --git a/Source/wtf/text/StringImpl.h b/Source/wtf/text/StringImpl.h
|
| index bf33deae45f3d3d5ded33600b83432419aea4d32..1a51e1821432babf4d879b5a31efe3258bb1c36d 100644
|
| --- a/Source/wtf/text/StringImpl.h
|
| +++ b/Source/wtf/text/StringImpl.h
|
| @@ -116,7 +116,7 @@ class WTF_EXPORT StringImpl {
|
| friend struct WTF::SubstringTranslator;
|
| friend struct WTF::UCharBufferTranslator;
|
|
|
| -private:
|
| +protected:
|
| // StringImpls are allocated out of the WTF buffer partition.
|
| void* operator new(size_t);
|
| void* operator new(size_t, void* ptr) { return ptr; }
|
| @@ -133,6 +133,7 @@ private:
|
| , m_isAtomic(false)
|
| , m_is8Bit(true)
|
| , m_isStatic(true)
|
| + , m_isBuffered(false)
|
| {
|
| // Ensure that the hash is computed so that AtomicStringHash can call existingHash()
|
| // with impunity. The empty string is special because it is never entered into
|
| @@ -149,6 +150,7 @@ private:
|
| , m_isAtomic(false)
|
| , m_is8Bit(false)
|
| , m_isStatic(true)
|
| + , m_isBuffered(false)
|
| {
|
| STRING_STATS_ADD_16BIT_STRING(m_length);
|
| hash();
|
| @@ -156,25 +158,27 @@ private:
|
|
|
| // FIXME: there has to be a less hacky way to do this.
|
| enum Force8Bit { Force8BitConstructor };
|
| - StringImpl(unsigned length, Force8Bit)
|
| + StringImpl(unsigned length, Force8Bit, bool isBuffered = false)
|
| : m_refCount(1)
|
| , m_length(length)
|
| , m_hash(0)
|
| , m_isAtomic(false)
|
| , m_is8Bit(true)
|
| , m_isStatic(false)
|
| + , m_isBuffered(isBuffered)
|
| {
|
| ASSERT(m_length);
|
| STRING_STATS_ADD_8BIT_STRING(m_length);
|
| }
|
|
|
| - StringImpl(unsigned length)
|
| + StringImpl(unsigned length, bool isBuffered = false)
|
| : m_refCount(1)
|
| , m_length(length)
|
| , m_hash(0)
|
| , m_isAtomic(false)
|
| , m_is8Bit(false)
|
| , m_isStatic(false)
|
| + , m_isBuffered(isBuffered)
|
| {
|
| ASSERT(m_length);
|
| STRING_STATS_ADD_16BIT_STRING(m_length);
|
| @@ -188,6 +192,7 @@ private:
|
| , m_isAtomic(false)
|
| , m_is8Bit(true)
|
| , m_isStatic(true)
|
| + , m_isBuffered(false)
|
| {
|
| }
|
|
|
| @@ -214,10 +219,12 @@ public:
|
|
|
| static PassRefPtr<StringImpl> createUninitialized(unsigned length, LChar*& data);
|
| static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& data);
|
| + static PassRefPtr<StringImpl> createBufferUninitialized(unsigned length, LChar*& data, void* holder);
|
| + static PassRefPtr<StringImpl> createBufferUninitialized(unsigned length, UChar*& data, void* holder);
|
|
|
| // Reallocate the StringImpl. The originalString must be only owned by the PassRefPtr.
|
| // Just like the input pointer of realloc(), the originalString can't be used after this function.
|
| - static PassRefPtr<StringImpl> reallocate(PassRefPtr<StringImpl> originalString, unsigned length);
|
| + static PassRefPtr<StringImpl> reallocate(PassRefPtr<StringImpl> originalString, unsigned length, void* holder);
|
|
|
| // If this StringImpl has only one reference, we can truncate the string by updating
|
| // its m_length property without actually re-allocating its buffer.
|
| @@ -228,6 +235,7 @@ public:
|
| m_length = length;
|
| }
|
|
|
| + void setLength(unsigned length) { m_length = length; }
|
| unsigned length() const { return m_length; }
|
| bool is8Bit() const { return m_is8Bit; }
|
|
|
| @@ -243,8 +251,9 @@ public:
|
| void setIsAtomic(bool isAtomic) { m_isAtomic = isAtomic; }
|
|
|
| bool isStatic() const { return m_isStatic; }
|
| + bool isBuffered() const { return m_isBuffered; }
|
|
|
| -private:
|
| +protected:
|
| // The high bits of 'hash' are always empty, but we prefer to store our flags
|
| // in the low bits because it makes them slightly more efficient to access.
|
| // So, we shift left and right when setting and getting our hash code.
|
| @@ -423,7 +432,7 @@ public:
|
| #endif
|
| static const UChar latin1CaseFoldTable[256];
|
|
|
| -private:
|
| +protected:
|
| template<typename CharType> static size_t allocationSize(unsigned length)
|
| {
|
| RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(CharType)));
|
| @@ -448,13 +457,14 @@ private:
|
| }
|
| #endif
|
|
|
| -private:
|
| +protected:
|
| unsigned m_refCount;
|
| unsigned m_length;
|
| mutable unsigned m_hash : 24;
|
| unsigned m_isAtomic : 1;
|
| unsigned m_is8Bit : 1;
|
| unsigned m_isStatic : 1;
|
| + unsigned m_isBuffered : 1;
|
| };
|
|
|
| template <>
|
|
|