diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 026fa62466..1681c2c216 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -56,7 +56,7 @@ struct EmptyString String::CharPointerType::CharType text; }; -static const EmptyString emptyString = { 0x3fffffff, sizeof (String::CharPointerType::CharType), 0 }; +static const EmptyString emptyString { 0x3fffffff, sizeof (String::CharPointerType::CharType), 0 }; //============================================================================== class StringHolder @@ -156,13 +156,13 @@ public: { auto* b = bufferFromText (text); - if (b != (StringHolder*) &emptyString) + if (! isEmptyString (b)) ++(b->refCount); } static inline void release (StringHolder* const b) noexcept { - if (b != (StringHolder*) &emptyString) + if (! isEmptyString (b)) if (--(b->refCount) == -1) delete[] reinterpret_cast (b); } @@ -182,7 +182,7 @@ public: { auto* b = bufferFromText (text); - if (b == (StringHolder*) &emptyString) + if (isEmptyString (b)) { auto newText = createUninitialisedBytes (numBytes); newText.writeNull(); @@ -217,6 +217,11 @@ private: - (reinterpret_cast (reinterpret_cast (128)->text) - 128)); } + static inline bool isEmptyString (StringHolder* other) + { + return (other->refCount.get() & 0x30000000) != 0; + } + void compileTimeChecks() { // Let me know if any of these assertions fail on your system!