From 0e3b10c509e31c9ee0b435bd611753ecea4f3740 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Feb 2012 14:18:37 +0000 Subject: [PATCH] Fix huge performance problem in wxStdInputStream when using MSVC8/9. Our overridden xsgetn() method was never called when using these compilers because they used their own, non-standard, _Xsgetn_s() instead. Because of this the stream was always read character by character which was very inefficient. Fix the problem by overriding _Xsgetn_s() for these compilers and explicitly forwarding it to xsgetn(). Closes #13926. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/stdstream.h | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index efa010c1f4..1fcd83c709 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -464,6 +464,7 @@ All: - Added "%z" support to wxDateTime::Format() and Parse() (Armel Asselin). - Add wxHTTP::SetPostBuffer(wxMemoryBuffer) and SetPostText() (Eran Ifrah). - Fix wrong time zone used in wxDateTime::UNow(). +- Fix performance of wxStdInputStream with MSVC8/9 (wsu). All (GUI): diff --git a/include/wx/stdstream.h b/include/wx/stdstream.h index e3f3a474fe..27d48d5c8b 100644 --- a/include/wx/stdstream.h +++ b/include/wx/stdstream.h @@ -47,6 +47,18 @@ protected: virtual int uflow(); virtual int pbackfail(int c = EOF); + // Special work around for VC8/9 (this bug was fixed in VC10 and later): + // these versions have non-standard _Xsgetn_s() that it being called from + // the stream code instead of xsgetn() and so our overridden implementation + // never actually gets used. To work around this, forward to it explicitly. +#if defined(__VISUALC8__) || defined(__VISUALC9__) + virtual std::streamsize + _Xsgetn_s(char *s, size_t WXUNUSED(size), std::streamsize n) + { + return xsgetn(s, n); + } +#endif // VC8 or VC9 + wxInputStream& m_stream; int m_lastChar; }; -- 2.45.2