Further tweaks to ConstString.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
5e3b067452
commit
91b9854932
|
@ -24,6 +24,10 @@
|
|||
} \
|
||||
\
|
||||
inline static int constexpr Length(const char* str) { return *str ? 1 + Length(str + 1) : 0; } \
|
||||
inline __ConstStringCharHolder* CloneHolder() const noexcept { \
|
||||
_str->AddReference(); \
|
||||
return _str; \
|
||||
} \
|
||||
\
|
||||
public: \
|
||||
name(const char* str, size_t size) \
|
||||
|
@ -32,15 +36,14 @@
|
|||
name() : _str(GetEmptyString()), _length(0), _hash(Hash("")) { GetEmptyString()->AddReference(); }; \
|
||||
explicit name(const char* str) : name(str, Length(str)){}; \
|
||||
explicit name(const std::string& str) : name(str.c_str(), str.size()){}; \
|
||||
name(const name& other) : _str(other._str), _length(other._length), _hash(other._hash) { \
|
||||
_str->AddReference(); \
|
||||
} \
|
||||
name(const name& other) : _str(other.CloneHolder()), _length(other._length), _hash(other._hash) {} \
|
||||
name& operator=(const name& other) { \
|
||||
if (_str == other._str) \
|
||||
if (_str == other._str) { \
|
||||
_str->AddReference(); \
|
||||
return *this; \
|
||||
} \
|
||||
_str->RemoveReference(); \
|
||||
_str = other._str; \
|
||||
_str->AddReference(); \
|
||||
_str = other.CloneHolder(); \
|
||||
_length = other._length; \
|
||||
_hash = other._hash; \
|
||||
return *this; \
|
||||
|
|
Loading…
Reference in New Issue