diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 1be83e5804..5e0ba4500b 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -1035,7 +1035,7 @@ public: Array argv; for (int i = 0; i < arguments.size(); ++i) if (arguments[i].isNotEmpty()) - argv.add (arguments[i].toUTF8().getAddress()); + argv.add (const_cast (arguments[i].toUTF8().getAddress())); argv.add (nullptr); diff --git a/modules/juce_core/text/juce_StringPool.cpp b/modules/juce_core/text/juce_StringPool.cpp index f8fd5a7869..039a30bf91 100644 --- a/modules/juce_core/text/juce_StringPool.cpp +++ b/modules/juce_core/text/juce_StringPool.cpp @@ -121,6 +121,16 @@ String StringPool::getPooledString (String::CharPointerType start, String::CharP return addPooledString (strings, StartEndString (start, end)); } +String StringPool::getPooledString (StringRef newString) +{ + if (newString.isEmpty()) + return String(); + + const ScopedLock sl (lock); + garbageCollectIfNeeded(); + return addPooledString (strings, newString.text); +} + String StringPool::getPooledString (const String& newString) { if (newString.isEmpty()) diff --git a/modules/juce_core/text/juce_StringPool.h b/modules/juce_core/text/juce_StringPool.h index 0aae600ac1..4de2186554 100644 --- a/modules/juce_core/text/juce_StringPool.h +++ b/modules/juce_core/text/juce_StringPool.h @@ -62,6 +62,11 @@ public: */ String getPooledString (const char* original); + /** Returns a pointer to a shared copy of the string that is passed in. + The pool will always return the same String object when asked for a string that matches it. + */ + String getPooledString (StringRef original); + /** Returns a pointer to a copy of the string that is passed in. The pool will always return the same String object when asked for a string that matches it. */ diff --git a/modules/juce_core/xml/juce_XmlElement.cpp b/modules/juce_core/xml/juce_XmlElement.cpp index 469f382a49..000df15d5f 100644 --- a/modules/juce_core/xml/juce_XmlElement.cpp +++ b/modules/juce_core/xml/juce_XmlElement.cpp @@ -72,7 +72,7 @@ XmlElement::XmlElement (const char* tag) } XmlElement::XmlElement (StringRef tag) - : tagName (StringPool::getGlobalPool().getPooledString (tag.text.getAddress())) + : tagName (StringPool::getGlobalPool().getPooledString (tag)) { sanityCheckTagName (tagName); }