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:
@@ -497,12 +497,13 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input)
|
|||||||
const wxChar *in_str = input.c_str();
|
const wxChar *in_str = input.c_str();
|
||||||
wxString output;
|
wxString output;
|
||||||
|
|
||||||
output.reserve(input.length());
|
|
||||||
|
|
||||||
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
|
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
|
||||||
{
|
{
|
||||||
if (*c == wxT('&'))
|
if (*c == wxT('&'))
|
||||||
{
|
{
|
||||||
|
if ( output.empty() )
|
||||||
|
output.reserve(input.length());
|
||||||
|
|
||||||
if (c - last > 0)
|
if (c - last > 0)
|
||||||
output.append(last, c - last);
|
output.append(last, c - last);
|
||||||
if ( *++c == wxT('\0') )
|
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'))
|
if (*last != wxT('\0'))
|
||||||
output.append(last);
|
output.append(last);
|
||||||
return output;
|
return output;
|
||||||
|
Reference in New Issue
Block a user