X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=xml-tree-inc.hpp;fp=xml-tree-inc.hpp;h=18c91e3dad2564b2cd5b06cfd8158d107ff1ad37;hb=158789da8352e9ad2ee3feeb39f59e5f64343438;hp=faf4538743fe3cfdef12ca9e669c5029bb2383b8;hpb=b9fb65602be2216e5b4545763471bcd282c1382b;p=SXSI%2FXMLTree.git diff --git a/xml-tree-inc.hpp b/xml-tree-inc.hpp index faf4538..18c91e3 100644 --- a/xml-tree-inc.hpp +++ b/xml-tree-inc.hpp @@ -41,15 +41,12 @@ inline uint32_t xml_tree::subtree_elements(xml_tree::node_t x) const int32_t size = bp_subtree_size(par, x) - 1; if (size <= 0) return 0; - size -= subtree_tags(x, xml_tree::PCDATA_OPEN_TAG_ID); - size -= subtree_tags(x, xml_tree::ATTRIBUTE_OPEN_TAG_ID); - size -= subtree_tags(x, xml_tree::ATTRIBUTE_DATA_OPEN_TAG_ID); - if (size < 3) return (uint32_t) size; - std::unordered_set::iterator it; - for(it = this->attribute_ids->begin(); - it != this->attribute_ids->end(); - ++it) - size -= subtree_tags(x, *it); + uint32_t num_texts = subtree_tags(x, xml_tree::PCDATA_OPEN_TAG_ID); + uint32_t num_atts = subtree_tags(x, xml_tree::ATTRIBUTE_OPEN_TAG_ID); + uint32_t num_att_data = subtree_tags(x, xml_tree::ATTRIBUTE_DATA_OPEN_TAG_ID); + size -= num_texts; + size -= num_atts; + size -= 2*num_att_data; return (uint32_t) size; }