Rework of empty string handler on ConstString.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c230f8b11c
commit
9bd30cb9c4
|
@ -1,6 +1,4 @@
|
|||
#include "ConstString.hpp"
|
||||
|
||||
Arbutils::__ConstStringCharHolder* Arbutils::CaseInsensitiveConstString::_emptyString =
|
||||
new Arbutils::__ConstStringCharHolder("", 0);
|
||||
|
||||
Arbutils::__ConstStringCharHolder* Arbutils::ConstString::_emptyString = new Arbutils::__ConstStringCharHolder("", 0);
|
||||
Arbutils::__ConstStringCharHolder* Arbutils::CaseInsensitiveConstString::__emptyString = nullptr;
|
||||
Arbutils::__ConstStringCharHolder* Arbutils::ConstString::__emptyString = nullptr;
|
|
@ -14,7 +14,12 @@
|
|||
__ConstStringCharHolder* _str = nullptr; \
|
||||
size_t _length; \
|
||||
uint32_t _hash; \
|
||||
static __ConstStringCharHolder* _emptyString; \
|
||||
static __ConstStringCharHolder* __emptyString; \
|
||||
static inline __ConstStringCharHolder* GetEmptyString() { \
|
||||
if (__emptyString == nullptr) \
|
||||
__emptyString = new __ConstStringCharHolder("", 0); \
|
||||
return __emptyString; \
|
||||
} \
|
||||
\
|
||||
hashFunction; \
|
||||
\
|
||||
|
@ -23,7 +28,7 @@
|
|||
public: \
|
||||
name(const char* str, size_t size) \
|
||||
: _str(new __ConstStringCharHolder(str, size)), _length(size), _hash(Hash(str)) {} \
|
||||
name() : _str(_emptyString), _length(0), _hash(Hash("")) { _emptyString->AddReference(); }; \
|
||||
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) { \
|
||||
|
|
Loading…
Reference in New Issue