diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index 1efdb396b..f6e209c3f 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -307,7 +307,7 @@ class NAZARA_CORE_API NzString : public NzHashable bool FillHash(NzAbstractHash* hash) const; inline void ReleaseString(); - static std::shared_ptr GetEmptyString(); + static const std::shared_ptr& GetEmptyString(); std::shared_ptr m_sharedString; diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index a1ba87b84..1566b32a5 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -1934,7 +1934,7 @@ bool NzString::IsEmpty() const bool NzString::IsNull() const { - return !m_sharedString.get(); + return m_sharedString.get() == GetEmptyString().get(); } bool NzString::IsNumber(nzUInt8 base, nzUInt32 flags) const @@ -2609,7 +2609,7 @@ NzString& NzString::Set(unsigned int rep, const char* string, unsigned int lengt if (totalSize > 0) { if (m_sharedString->capacity >= totalSize) - { + { EnsureOwnership(true); m_sharedString->size = totalSize; @@ -2642,7 +2642,7 @@ NzString& NzString::Set(const char* string, unsigned int length) if (length > 0) { if (m_sharedString->capacity >= length) - { + { EnsureOwnership(true); m_sharedString->size = length; @@ -4198,7 +4198,7 @@ bool NzString::FillHash(NzAbstractHash* hash) const return true; } -std::shared_ptr NzString::GetEmptyString() +const std::shared_ptr& NzString::GetEmptyString() { static auto emptyString = std::make_shared();