Improved code
Fixed Directory being copyable Fixed ByteArray and String self-assignation Made it clear Clock is copyable Former-commit-id: 36702d8a389abe6d3faa1e283d9a20f0326041a6
This commit is contained in:
parent
221e2583ac
commit
8b34e21e2f
|
|
@ -19,6 +19,7 @@ class NAZARA_API NzClock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzClock(nzUInt64 startingValue = 0, bool paused = false);
|
NzClock(nzUInt64 startingValue = 0, bool paused = false);
|
||||||
|
NzClock(const NzClock& clock) = default;
|
||||||
|
|
||||||
float GetSeconds() const;
|
float GetSeconds() const;
|
||||||
nzUInt64 GetMicroseconds() const;
|
nzUInt64 GetMicroseconds() const;
|
||||||
|
|
@ -30,6 +31,8 @@ class NAZARA_API NzClock
|
||||||
void Restart();
|
void Restart();
|
||||||
void Unpause();
|
void Unpause();
|
||||||
|
|
||||||
|
NzClock& operator=(const NzClock& clock) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NazaraMutexAttrib(m_mutex, mutable)
|
NazaraMutexAttrib(m_mutex, mutable)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#define NAZARA_DIRECTORY_HPP
|
#define NAZARA_DIRECTORY_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/NonCopyable.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
|
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||||
|
|
@ -27,7 +28,7 @@
|
||||||
|
|
||||||
class NzDirectoryImpl;
|
class NzDirectoryImpl;
|
||||||
|
|
||||||
class NAZARA_API NzDirectory
|
class NAZARA_API NzDirectory : NzNonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzDirectory();
|
NzDirectory();
|
||||||
|
|
|
||||||
|
|
@ -404,11 +404,14 @@ nzUInt8 NzByteArray::operator[](unsigned int pos) const
|
||||||
|
|
||||||
NzByteArray& NzByteArray::operator=(const NzByteArray& array)
|
NzByteArray& NzByteArray::operator=(const NzByteArray& array)
|
||||||
{
|
{
|
||||||
|
if (this != &array)
|
||||||
|
{
|
||||||
ReleaseArray();
|
ReleaseArray();
|
||||||
|
|
||||||
m_sharedArray = array.m_sharedArray;
|
m_sharedArray = array.m_sharedArray;
|
||||||
if (m_sharedArray != &emptyArray)
|
if (m_sharedArray != &emptyArray)
|
||||||
m_sharedArray->refCount++;
|
m_sharedArray->refCount++;
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2785,35 +2785,19 @@ NzString& NzString::Set(const char* string, unsigned int length)
|
||||||
|
|
||||||
NzString& NzString::Set(const std::string& string)
|
NzString& NzString::Set(const std::string& string)
|
||||||
{
|
{
|
||||||
if (string.size() > 0)
|
return Set(string.data(), string.size());
|
||||||
{
|
|
||||||
if (m_sharedString->capacity >= string.size())
|
|
||||||
EnsureOwnership(true);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReleaseString();
|
|
||||||
|
|
||||||
m_sharedString = new SharedString;
|
|
||||||
m_sharedString->capacity = string.size();
|
|
||||||
m_sharedString->string = new char[string.size()+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sharedString->size = string.size();
|
|
||||||
std::memcpy(m_sharedString->string, string.c_str(), string.size()+1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ReleaseString();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString& NzString::Set(const NzString& string)
|
NzString& NzString::Set(const NzString& string)
|
||||||
{
|
{
|
||||||
|
if (this != &string)
|
||||||
|
{
|
||||||
ReleaseString();
|
ReleaseString();
|
||||||
|
|
||||||
m_sharedString = string.m_sharedString;
|
m_sharedString = string.m_sharedString;
|
||||||
if (m_sharedString != &emptyString)
|
if (m_sharedString != &emptyString)
|
||||||
m_sharedString->refCount++;
|
m_sharedString->refCount++;
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue