summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:54:18 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:54:18 +0000
commit589947da0bf3e446f0499c3052821a5019a0e94e (patch)
treeeab9f2d2a69a8918335a6e58c29c2a59cd4631e6
parent9a0464bdc25e4b20907f5d19a7773179c930ff08 (diff)
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
-rw-r--r--src/pugixml.cpp19
1 files changed, 6 insertions, 13 deletions
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<size_t>(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<size_t>(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
{