don't write the strings to the stream one char at a time, it's *horribly* slow
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16150 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -412,33 +412,41 @@ void wxTextOutputStream::WriteDouble(double d)
|
|||||||
|
|
||||||
void wxTextOutputStream::WriteString(const wxString& string)
|
void wxTextOutputStream::WriteString(const wxString& string)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < string.Len(); i++)
|
size_t len = string.length();
|
||||||
|
|
||||||
|
wxString out;
|
||||||
|
out.reserve(len);
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < len; i++ )
|
||||||
{
|
{
|
||||||
wxChar c = string[i];
|
const wxChar c = string[i];
|
||||||
if (c == wxT('\n'))
|
if ( c == wxT('\n') )
|
||||||
{
|
{
|
||||||
if (m_mode == wxEOL_DOS)
|
switch ( m_mode )
|
||||||
{
|
{
|
||||||
c = wxT('\r');
|
case wxEOL_DOS:
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
out << _T("\r\n");
|
||||||
c = wxT('\n');
|
continue;
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
|
||||||
} else
|
case wxEOL_MAC:
|
||||||
if (m_mode == wxEOL_MAC)
|
out << _T('\r');
|
||||||
{
|
continue;
|
||||||
c = wxT('\r');
|
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
default:
|
||||||
} else
|
wxFAIL_MSG( _T("unknown EOL mode in wxTextOutputStream") );
|
||||||
{
|
// fall through
|
||||||
c = wxT('\n');
|
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
case wxEOL_UNIX:
|
||||||
|
// don't treat '\n' specially
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
out << c;
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NB: we don't need to write the trailing NUL here
|
||||||
|
m_output.Write(out.c_str(), out.length() * sizeof(wxChar));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextOutputStream& wxTextOutputStream::operator<<(const wxChar *string)
|
wxTextOutputStream& wxTextOutputStream::operator<<(const wxChar *string)
|
||||||
|
Reference in New Issue
Block a user