backported deallocation fix for Visual C++ Multithreaded non DLL runtime
this fix only has a performance impact on wxString in this configuration git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20769 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -190,12 +190,19 @@ struct WXDLLEXPORT wxStringData
|
|||||||
// lock/unlock
|
// lock/unlock
|
||||||
void Lock() { if ( !IsEmpty() ) nRefs++; }
|
void Lock() { if ( !IsEmpty() ) nRefs++; }
|
||||||
|
|
||||||
// VC++ will refuse to inline this function but profiling shows that it
|
// VC++ will refuse to inline Unlock but profiling shows that it is wrong
|
||||||
// is wrong
|
|
||||||
#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
|
#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
|
||||||
__forceinline
|
__forceinline
|
||||||
#endif
|
#endif
|
||||||
|
// VC++ free must take place in same DLL as allocation when using non dll
|
||||||
|
// run-time library (e.g. Multithreaded instead of Multithreaded DLL)
|
||||||
|
#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL)
|
||||||
|
void Unlock() { if ( !IsEmpty() && --nRefs == 0) Free(); }
|
||||||
|
// we must not inline deallocation since allocation is not inlined
|
||||||
|
void Free();
|
||||||
|
#else
|
||||||
void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); }
|
void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); }
|
||||||
|
#endif
|
||||||
|
|
||||||
// if we had taken control over string memory (GetWriteBuf), it's
|
// if we had taken control over string memory (GetWriteBuf), it's
|
||||||
// intentionally put in invalid state
|
// intentionally put in invalid state
|
||||||
|
@@ -160,6 +160,18 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str)
|
|||||||
#define STATISTICS_ADD(av, val)
|
#define STATISTICS_ADD(av, val)
|
||||||
#endif // WXSTRING_STATISTICS
|
#endif // WXSTRING_STATISTICS
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// wxStringData core
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL)
|
||||||
|
# pragma message (__FILE__ ": building with Multithreaded non DLL runtime has a performance impact on wxString!")
|
||||||
|
void wxStringData::Free()
|
||||||
|
{
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// wxString class core
|
// wxString class core
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
Reference in New Issue
Block a user