From 589947da0bf3e446f0499c3052821a5019a0e94e Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 29 Aug 2010 15:54:18 +0000 Subject: XPath: Minor xpath_string refactoring, minor xpath_string::append fix git-svn-id: http://pugixml.googlecode.com/svn/trunk@701 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 0a83c81..b284d3b 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4751,16 +4751,10 @@ namespace { assert(begin <= end); - if (begin != end) - { - _buffer = duplicate_string(begin, static_cast(end - begin)); - _uses_heap = true; - } - else - { - _buffer = PUGIXML_TEXT(""); - _uses_heap = false; - } + bool empty = (begin == end); + + _buffer = empty ? PUGIXML_TEXT("") : duplicate_string(begin, static_cast(end - begin)); + _uses_heap = !empty; } xpath_string(const xpath_string& o) @@ -4788,11 +4782,10 @@ namespace // skip empty sources if (!*o._buffer) return; - // fast append for empty target and constant source - if (!*_buffer && !o._uses_heap) + // fast append for constant empty target and constant source + if (!*_buffer && !_uses_heap && !o._uses_heap) { _buffer = o._buffer; - _uses_heap = false; } else { -- cgit v1.2.3