18 #include "precompiled.h"
25 #include <boost/unordered_map.hpp>
57 return fnv_hash(key.c_str(), key.length());
83 return (proxy.
len == key.length() && memcmp(proxy.
str, key.c_str(), proxy.
len) == 0);
89 #define X(id) CStrIntern str_##id(#id);
90 #define X2(id, str) CStrIntern str_##id(str);
102 #if BOOST_VERSION >= 104200
104 boost::unordered_map<StringsKey, shared_ptr<CStrInternInternals> >::iterator it =
108 boost::unordered_map<StringsKey, shared_ptr<CStrInternInternals> >::iterator it =
113 return it->second.get();
116 g_Strings.insert(std::make_pair(internals->data, internals));
117 return internals.get();
122 *
this = str__emptystring;
142 return m->
data.c_str();
147 return m->
data.length();
bool operator==(const CStrInternInternals &b) const
CStrInternInternals & operator=(const CStrInternInternals &)
const std::string & string() const
Returns as std::string.
size_t length() const
Returns length of string in bytes.
static boost::unordered_map< StringsKey, shared_ptr< CStrInternInternals >, StringsKeyHash > g_Strings
u32 GetHash() const
Returns cached FNV1-A hash of the string.
const char * c_str() const
Returns null-terminated string.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
static CStrInternInternals * GetString(const char *str, size_t len)
CStrInternInternals(const char *str, size_t len)
size_t operator()(const StringsKey &key) const
size_t operator()(const StringsKeyProxy &key) const
u32 fnv_hash(const void *buf, size_t len)
rationale: this algorithm was chosen because it delivers 'good' results for string data and is relati...
bool IsMainThread()
Returns whether the current thread is the 'main' thread (i.e.
bool operator()(const StringsKeyProxy &proxy, const StringsKey &key) const