From ee71546f91d56567a2249e68317fa519d7fddcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 22 Aug 2007 06:18:48 +0000 Subject: [PATCH] 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 --- src/html/htmlpars.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 7efb69af34..354f2b2466 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -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;