optimized wxHtmlEntitiesParser::Parse() for the common case of no entities in the input

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-08-22 06:18:48 +00:00
parent 818a665f80
commit ee71546f91

View File

@@ -497,12 +497,13 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input)
const wxChar *in_str = input.c_str();
wxString output;
output.reserve(input.length());
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
{
if (*c == wxT('&'))
{
if ( output.empty() )
output.reserve(input.length());
if (c - last > 0)
output.append(last, c - last);
if ( *++c == wxT('\0') )
@@ -531,6 +532,8 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input)
}
}
}
if (last == in_str) // common case: no entity
return input;
if (*last != wxT('\0'))
output.append(last);
return output;