From e7b0e52068bd292bccfb0ae886c770578604cf6d Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 29 Aug 2010 15:43:28 +0000 Subject: XPath: Fixed default variable values, minor algorithm refactoring git-svn-id: http://pugixml.googlecode.com/svn/trunk@684 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 7981d16..95ac883 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4540,20 +4540,6 @@ namespace pstd rhs = temp; } - template void copy(I begin, I end, J target) - { - while (begin != end) *target++ = *begin++; - } - - template I find(I begin, I end, T elem) - { - for (I it = begin; it != end; ++it) - if (*it == elem) - return it; - - return end; - } - template I min_element(I begin, I end, const Pred& pred) { I result = begin; @@ -5334,18 +5320,30 @@ namespace struct xpath_variable_boolean: xpath_variable { + xpath_variable_boolean(): value(false) + { + } + bool value; char_t name[1]; }; struct xpath_variable_number: xpath_variable { + xpath_variable_number(): value(0) + { + } + double value; char_t name[1]; }; struct xpath_variable_string: xpath_variable { + xpath_variable_string(): value(0) + { + } + ~xpath_variable_string() { if (value) global_deallocate(value); @@ -5744,8 +5742,7 @@ namespace pugi xpath_node* storage = static_cast(global_allocate(capacity * sizeof(xpath_node))); if (!storage) return; // $$ out of memory - pstd::copy(_begin, _end, storage); - // memcpy(storage, _begin, size * sizeof(xpath_node)); + memcpy(storage, _begin, size * sizeof(xpath_node)); if (_begin != &_storage) global_deallocate(_begin); @@ -5754,8 +5751,7 @@ namespace pugi _eos = storage + capacity; } - pstd::copy(begin, end, _end); - // memcpy(_end, begin, count * sizeof(xpath_node)); + memcpy(_end, begin, count * sizeof(xpath_node)); _end += count; } @@ -7989,9 +7985,7 @@ namespace pugi // QName or NCName:* else { - const char_t* colon_pos = pstd::find(nt_name.begin, nt_name.end, ':'); - - if (colon_pos + 2 == nt_name.end && colon_pos[1] == '*') // NCName:* + if (nt_name.end - nt_name.begin > 2 && nt_name.end[-2] == ':' && nt_name.end[-1] == '*') // NCName:* { nt_name.end--; // erase * -- cgit v1.2.3