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"
|
#include "ConstString.hpp"
|
||||||
|
|
||||||
Arbutils::__ConstStringCharHolder* Arbutils::CaseInsensitiveConstString::_emptyString =
|
Arbutils::__ConstStringCharHolder* Arbutils::CaseInsensitiveConstString::__emptyString = nullptr;
|
||||||
new Arbutils::__ConstStringCharHolder("", 0);
|
Arbutils::__ConstStringCharHolder* Arbutils::ConstString::__emptyString = nullptr;
|
||||||
|
|
||||||
Arbutils::__ConstStringCharHolder* Arbutils::ConstString::_emptyString = new Arbutils::__ConstStringCharHolder("", 0);
|
|
|
@ -14,7 +14,12 @@
|
||||||
__ConstStringCharHolder* _str = nullptr; \
|
__ConstStringCharHolder* _str = nullptr; \
|
||||||
size_t _length; \
|
size_t _length; \
|
||||||
uint32_t _hash; \
|
uint32_t _hash; \
|
||||||
static __ConstStringCharHolder* _emptyString; \
|
static __ConstStringCharHolder* __emptyString; \
|
||||||
|
static inline __ConstStringCharHolder* GetEmptyString() { \
|
||||||
|
if (__emptyString == nullptr) \
|
||||||
|
__emptyString = new __ConstStringCharHolder("", 0); \
|
||||||
|
return __emptyString; \
|
||||||
|
} \
|
||||||
\
|
\
|
||||||
hashFunction; \
|
hashFunction; \
|
||||||
\
|
\
|
||||||
|
@ -23,7 +28,7 @@
|
||||||
public: \
|
public: \
|
||||||
name(const char* str, size_t size) \
|
name(const char* str, size_t size) \
|
||||||
: _str(new __ConstStringCharHolder(str, size)), _length(size), _hash(Hash(str)) {} \
|
: _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 char* str) : name(str, Length(str)){}; \
|
||||||
explicit name(const std::string& str) : name(str.c_str(), str.size()){}; \
|
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) { \
|
name(const name& other) : _str(other._str), _length(other._length), _hash(other._hash) { \
|
||||||
|
|
Loading…
Reference in New Issue