Fix performance of wxHtmlParser::SkipCommentTag() in UTF-8 build.

Avoid computing the difference between two potentially distant
iterators, which is O(1) in wchar_t build, but O(n) in UTF-8 one.

See #13445.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2012-05-07 11:15:31 +00:00
parent 2a715bcb3c
commit e4f762f416

View File

@ -957,12 +957,14 @@ wxHtmlParser::SkipCommentTag(wxString::const_iterator& start,
wxString::const_iterator p = start;
// comments begin with "<!--" in HTML 4.0
if ( end - start < 4 || *++p != '!' || *++p != '-' || *++p != '-' )
{
// not a comment at all
return false;
}
// Comments begin with "<!--" in HTML 4.0; anything shorter or not containing
// these characters is not a comment and we're not going to skip it.
if ( ++p == end || *p != '!' )
return false;
if ( ++p == end || *p != '-' )
return false;
if ( ++p == end || *p != '-' )
return false;
// skip the start of the comment tag in any case, if we don't find the
// closing tag we should ignore broken markup