From a3c386c4bd71ba45bb14c69923ec17860a5c7c6f Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Tue, 10 Nov 2009 11:26:42 +0000 Subject: More branch probability tuning git-svn-id: http://pugixml.googlecode.com/svn/trunk@236 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 7114747..0a50497 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -692,7 +692,13 @@ namespace { while (!is_chartype(*s, ct_parse_pcdata)) ++s; - if (opt_eol && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair + if (*s == '<') // PCDATA ends here + { + *g.flush(s) = 0; + + return s + 1; + } + else if (opt_eol && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair { *s++ = '\n'; // replace first one with 0x0a @@ -702,12 +708,6 @@ namespace { s = strconv_escape(s, g); } - else if (*s == '<') // PCDATA ends here - { - *g.flush(s) = 0; - - return s + 1; - } else if (*s == 0) { return s; @@ -741,22 +741,35 @@ namespace gap g; - // Trim whitespaces - if (opt_wnorm) + // trim leading whitespaces + if (opt_wnorm && is_chartype(*s, ct_space)) { char* str = s; - while (is_chartype(*str, ct_space)) ++str; + do ++str; + while (is_chartype(*str, ct_space)); - if (str != s) - g.push(s, str - s); + g.push(s, str - s); } while (true) { while (!is_chartype(*s, (opt_wnorm || opt_wconv) ? ct_parse_attr_ws : ct_parse_attr)) ++s; - if (opt_wnorm && is_chartype(*s, ct_space)) + if (*s == end_quote) + { + char* str = g.flush(s); + + if (opt_wnorm) + { + do *str-- = 0; + while (is_chartype(*str, ct_space)); + } + else *str = 0; + + return s + 1; + } + else if (opt_wnorm && is_chartype(*s, ct_space)) { *s++ = ' '; @@ -788,19 +801,6 @@ namespace if (*s == '\n') g.push(s, 1); } - else if (*s == end_quote) - { - char* str = g.flush(s); - - if (opt_wnorm) - { - do *str-- = 0; - while (is_chartype(*str, ct_space)); - } - else *str = 0; - - return s + 1; - } else if (opt_escape && *s == '&') { s = strconv_escape(s, g); -- cgit v1.2.3