From 5ff56a6d68ce6fbab0980232d95b5d190e2ecdcf Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 9 May 2010 20:37:49 +0000 Subject: Removed document order optimization (it helps on a tiny percentage of queries), XPath tests now compute their own order git-svn-id: http://pugixml.googlecode.com/svn/trunk@400 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 41 ++++++----------------------------------- src/pugixml.hpp | 9 +++------ src/pugixpath.cpp | 6 ------ 3 files changed, 9 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 27c2960..fcd40b1 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -262,7 +262,7 @@ namespace pugi struct xml_attribute_struct { /// Default ctor - xml_attribute_struct(): document_order(0), name_allocated(false), value_allocated(false), name(0), value(0), prev_attribute(0), next_attribute(0) + xml_attribute_struct(): padding(0), name_allocated(false), value_allocated(false), name(0), value(0), prev_attribute(0), next_attribute(0) { } @@ -281,7 +281,7 @@ namespace pugi } } - unsigned int document_order : 30; ///< Document order value + unsigned int padding : 30; unsigned int name_allocated : 1; unsigned int value_allocated : 1; @@ -297,7 +297,7 @@ namespace pugi { /// Default ctor /// \param type - node type - xml_node_struct(xml_node_type type = node_element): name_allocated(false), value_allocated(false), document_order(0), type(type), parent(0), name(0), value(0), first_child(0), last_child(0), prev_sibling(0), next_sibling(0), first_attribute(0), last_attribute(0) + xml_node_struct(xml_node_type type = node_element): name_allocated(false), value_allocated(false), padding(0), type(type), parent(0), name(0), value(0), first_child(0), last_child(0), prev_sibling(0), next_sibling(0), first_attribute(0), last_attribute(0) { } @@ -357,7 +357,7 @@ namespace pugi unsigned int name_allocated : 1; unsigned int value_allocated : 1; - unsigned int document_order : 27; ///< Document order value + unsigned int padding : 27; unsigned int type : 3; ///< Node type; see xml_node_type. xml_node_struct* parent; ///< Pointer to parent @@ -2890,7 +2890,7 @@ namespace pugi unsigned int xml_attribute::document_order() const { - return _attr ? _attr->document_order : 0; + return 0; } xml_attribute& xml_attribute::operator=(const char_t* rhs) @@ -3683,35 +3683,7 @@ namespace pugi unsigned int xml_node::document_order() const { - return _root ? _root->document_order : 0; - } - - void xml_node::precompute_document_order_impl() - { - if (type() != node_document) return; - - unsigned int current = 1; - xml_node cur = *this; - - for (;;) - { - cur._root->document_order = current++; - - for (xml_attribute a = cur.first_attribute(); a; a = a.next_attribute()) - a._attr->document_order = current++; - - if (cur.first_child()) - cur = cur.first_child(); - else if (cur.next_sibling()) - cur = cur.next_sibling(); - else - { - while (cur && !cur.next_sibling()) cur = cur.parent(); - cur = cur.next_sibling(); - - if (!cur) break; - } - } + return 0; } void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, encoding_t encoding, unsigned int depth) const @@ -4154,7 +4126,6 @@ namespace pugi void xml_document::precompute_document_order() { - precompute_document_order_impl(); } #ifndef PUGIXML_NO_STL diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 8b4a733..83c4ee0 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -644,7 +644,7 @@ namespace pugi bool as_bool() const; /// \internal Document order or 0 if not set - unsigned int document_order() const; + PUGIXML_DEPRECATED unsigned int document_order() const; public: /** @@ -787,9 +787,6 @@ namespace pugi /// \internal Initializing ctor explicit xml_node(xml_node_struct* p); - /// \internal Precompute document order (valid only for document node) - void precompute_document_order_impl(); - /// \internal Get allocator xml_allocator& get_allocator() const; @@ -1457,7 +1454,7 @@ namespace pugi #endif /// \internal Document order or 0 if not set - unsigned int document_order() const; + PUGIXML_DEPRECATED unsigned int document_order() const; /** * Print subtree to writer @@ -2019,7 +2016,7 @@ namespace pugi * Compute document order for the whole tree * Sometimes this makes evaluation of XPath queries faster. */ - void precompute_document_order(); + PUGIXML_DEPRECATED void precompute_document_order(); }; #ifndef PUGIXML_NO_XPATH diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp index dc25a0e..0059f78 100644 --- a/src/pugixpath.cpp +++ b/src/pugixpath.cpp @@ -213,12 +213,6 @@ namespace { bool operator()(const xpath_node& lhs, const xpath_node& rhs) const { - unsigned int lo = lhs.attribute() ? lhs.attribute().document_order() : lhs.node().document_order(); - unsigned int ro = rhs.attribute() ? rhs.attribute().document_order() : rhs.node().document_order(); - - if (lo != 0 && ro != 0) - return lo < ro; - xml_node ln = lhs.node(), rn = rhs.node(); if (lhs.attribute() && rhs.attribute()) -- cgit v1.2.3