X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e810df36b3d5e73e53e2d536802df0174c571bb2..6cc970f33269027d7c1fe58a6a93292d41b24217:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 98d5c6da71..b66afd79ae 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -607,13 +607,13 @@ private: // enough) -- luckily we don't need it then neither as static __thread // variables are initialized by 0 anyhow then and so we can use the variable // directly - static Cache& GetCache() + WXEXPORT static Cache& GetCache() { static wxTLS_TYPE(Cache) s_cache; return wxTLS_VALUE(s_cache); } - + // this helper struct is used to ensure that GetCache() is called during // static initialization time, i.e. before any threads creation, as otherwise // the static s_cache construction inside GetCache() wouldn't be MT-safe @@ -671,7 +671,15 @@ private: // profiling seems to show a small but consistent gain if we use this // simple loop instead of starting from the last used element (there are // a lot of misses in this function...) - for ( Cache::Element *c = GetCacheBegin(); c != GetCacheEnd(); c++ ) + Cache::Element * const cacheBegin = GetCacheBegin(); +#ifndef wxHAS_COMPILER_TLS + // during destruction tls calls may return NULL, in this case return NULL + // immediately without accessing anything else + if ( cacheBegin == NULL ) + return NULL; +#endif + Cache::Element * const cacheEnd = GetCacheEnd(); + for ( Cache::Element *c = cacheBegin; c != cacheEnd; c++ ) { if ( c->str == this ) return c; @@ -1450,12 +1458,7 @@ public: // truncate the string to given length wxString& Truncate(size_t uiLen); // empty string contents - void Empty() - { - Truncate(0); - - wxASSERT_MSG( empty(), _T("string not empty after call to Empty()?") ); - } + void Empty() { clear(); } // empty the string and free memory void Clear() { clear(); }