]> git.saurik.com Git - wxWidgets.git/commitdiff
improved deallocation fix for Visual C++ Multithreaded non DLL runtime
authorGilles Depeyrot <gilles_depeyrot@mac.com>
Thu, 29 May 2003 14:03:37 +0000 (14:03 +0000)
committerGilles Depeyrot <gilles_depeyrot@mac.com>
Thu, 29 May 2003 14:03:37 +0000 (14:03 +0000)
so that it only has a performance impact on wxString in this configuration

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h
src/common/string.cpp

index 852f67115b56b15c22c0ed502e9f05e042c4d145..229b69b2f2e87f9a41e38b13b8dd6323980f2eae 100644 (file)
@@ -190,17 +190,19 @@ struct WXDLLEXPORT wxStringData
   // lock/unlock
   void  Lock()   { if ( !IsEmpty() ) nRefs++;                    }
 
-  // VC++ will refuse to inline this function but profiling shows that it
-  // is wrong
+  // VC++ will refuse to inline Unlock but profiling shows that it is wrong
 #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
   __forceinline
 #endif
-  void  Unlock() { if ( !IsEmpty() && --nRefs == 0) Free();  }
-
   // 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();  }
+#endif
 
   // if we had taken control over string memory (GetWriteBuf), it's
   // intentionally put in invalid state
index d0b3facc6b40bd21f8c5974004592df0cef3350b..2a3ce18e41040cb034cdb906a5eddfc0c678cae7 100644 (file)
@@ -164,10 +164,13 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str)
 // wxStringData class deallocation
 // ===========================================================================
 
+#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