Core/String: Fix IsNull() method (thanks to Unit tests)
Former-commit-id: dd4828c3c0e2d3423094cf018e70fd74deac0740
This commit is contained in:
parent
859544eaa7
commit
466720abec
|
|
@ -307,7 +307,7 @@ class NAZARA_CORE_API NzString : public NzHashable
|
||||||
bool FillHash(NzAbstractHash* hash) const;
|
bool FillHash(NzAbstractHash* hash) const;
|
||||||
inline void ReleaseString();
|
inline void ReleaseString();
|
||||||
|
|
||||||
static std::shared_ptr<SharedString> GetEmptyString();
|
static const std::shared_ptr<SharedString>& GetEmptyString();
|
||||||
|
|
||||||
std::shared_ptr<SharedString> m_sharedString;
|
std::shared_ptr<SharedString> m_sharedString;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1934,7 +1934,7 @@ bool NzString::IsEmpty() const
|
||||||
|
|
||||||
bool NzString::IsNull() const
|
bool NzString::IsNull() const
|
||||||
{
|
{
|
||||||
return !m_sharedString.get();
|
return m_sharedString.get() == GetEmptyString().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzString::IsNumber(nzUInt8 base, nzUInt32 flags) const
|
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 (totalSize > 0)
|
||||||
{
|
{
|
||||||
if (m_sharedString->capacity >= totalSize)
|
if (m_sharedString->capacity >= totalSize)
|
||||||
{
|
{
|
||||||
EnsureOwnership(true);
|
EnsureOwnership(true);
|
||||||
|
|
||||||
m_sharedString->size = totalSize;
|
m_sharedString->size = totalSize;
|
||||||
|
|
@ -2642,7 +2642,7 @@ NzString& NzString::Set(const char* string, unsigned int length)
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
if (m_sharedString->capacity >= length)
|
if (m_sharedString->capacity >= length)
|
||||||
{
|
{
|
||||||
EnsureOwnership(true);
|
EnsureOwnership(true);
|
||||||
|
|
||||||
m_sharedString->size = length;
|
m_sharedString->size = length;
|
||||||
|
|
@ -4198,7 +4198,7 @@ bool NzString::FillHash(NzAbstractHash* hash) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<NzString::SharedString> NzString::GetEmptyString()
|
const std::shared_ptr<NzString::SharedString>& NzString::GetEmptyString()
|
||||||
{
|
{
|
||||||
static auto emptyString = std::make_shared<SharedString>();
|
static auto emptyString = std::make_shared<SharedString>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue