summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:43:28 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:43:28 +0000
commite7b0e52068bd292bccfb0ae886c770578604cf6d (patch)
treea2ee0a08c1a557798b6d92bbdf7a11018ea377f8 /src
parent771c8ecc2f242a7dd8f45ebd91fd253ba37a2a65 (diff)
XPath: Fixed default variable values, minor algorithm refactoring
git-svn-id: http://pugixml.googlecode.com/svn/trunk@684 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src')
-rw-r--r--src/pugixml.cpp36
1 files changed, 15 insertions, 21 deletions
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 <typename I, typename J> void copy(I begin, I end, J target)
- {
- while (begin != end) *target++ = *begin++;
- }
-
- template <typename I, typename T> I find(I begin, I end, T elem)
- {
- for (I it = begin; it != end; ++it)
- if (*it == elem)
- return it;
-
- return end;
- }
-
template <typename I, typename Pred> 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<xpath_node*>(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 *