projects
/
SXSI
/
XMLTree.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6eb6b7b
)
Optimize subtree_elements by calling find_close only once.
author
Kim Nguyễn
<kn@lri.fr>
Tue, 24 Apr 2012 13:47:38 +0000
(15:47 +0200)
committer
Kim Nguyễn
<kn@lri.fr>
Tue, 24 Apr 2012 13:47:38 +0000
(15:47 +0200)
xml-tree.cpp
patch
|
blob
|
history
diff --git
a/xml-tree.cpp
b/xml-tree.cpp
index
8c0386e
..
84d42e2
100644
(file)
--- a/
xml-tree.cpp
+++ b/
xml-tree.cpp
@@
-344,20
+344,18
@@
xml_tree* xml_tree::load(int fd, char* name, bool load_tc, int sf)
uint32_t xml_tree::subtree_elements(xml_tree::node_t x) const
{
uint32_t xml_tree::subtree_elements(xml_tree::node_t x) const
{
-
- uint32_t size =
bp_subtree_size(par, x)
;
+ xml_tree::node_t fin = bp_find_close(par, x);
+ uint32_t size =
(fin - x)/2
;
if (x == root()){
x = bp_first_child(par,x);
size = size - 1;
};
if (x == root()){
x = bp_first_child(par,x);
size = size - 1;
};
- int s = x + 2*size - 1;
int ntext =
int ntext =
- tags->rank(xml_tree::PCDATA_OPEN_TAG_ID,
s
) -
+ tags->rank(xml_tree::PCDATA_OPEN_TAG_ID,
fin
) -
tags->rank(xml_tree::PCDATA_OPEN_TAG_ID, x-1);
size = size - ntext;
tags->rank(xml_tree::PCDATA_OPEN_TAG_ID, x-1);
size = size - ntext;
- xml_tree::node_t fin = bp_find_close(par, x);
xml_tree::node_t y = tags->select_next(xml_tree::ATTRIBUTE_OPEN_TAG_ID, x);
while (y != xml_tree::NIL && y < fin){
size -= subtree_size(y);
xml_tree::node_t y = tags->select_next(xml_tree::ATTRIBUTE_OPEN_TAG_ID, x);
while (y != xml_tree::NIL && y < fin){
size -= subtree_size(y);