Commit 984a9aed authored by Kasimier T. Buchcik's avatar Kasimier T. Buchcik

Removed a memcpy if xmlXPathNodeSetMerge(); it seems we really need to

* xpath.c: Removed a memcpy if xmlXPathNodeSetMerge(); it
  seems we really need to walk the whole list, since those
  nastly namespace nodes need to be added with
  xmlXPathNodeSetDupNs(); thus a pure memcpy is not possible.
  A flag on the node-set indicating if namespace nodes are in
  the set would help here; this is the 3rd flag which would
  be usefull with node-sets. The current flags I have in mind:
  1) Is a node-set already sorted?
     This would allow for rebust and optimizable sorting
     behaviour.
  2) Of what type are the nodes in the set (or of mixed type)?
     This would allow for faster merging of node-sets.
  3) Are namespace nodes in the set?
     This would allow to skipp all the namespace node specific
     special handling. Faster node-set merging if the first
     set is empty; just memcpy the set.
parent 5691f436
Wed May 24 10:54:25 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xpath.c: Removed a memcpy if xmlXPathNodeSetMerge(); it
seems we really need to walk the whole list, since those
nastly namespace nodes need to be added with
xmlXPathNodeSetDupNs(); thus a pure memcpy is not possible.
A flag on the node-set indicating if namespace nodes are in
the set would help here; this is the 3rd flag which would
be usefull with node-sets. The current flags I have in mind:
1) Is a node-set already sorted?
This would allow for rebust and optimizable sorting
behaviour.
2) Of what type are the nodes in the set (or of mixed type)?
This would allow for faster merging of node-sets.
3) Are namespace nodes in the set?
This would allow to skipp all the namespace node specific
special handling. Faster node-set merging if the first
set is empty; just memcpy the set.
Mon May 22 17:14:00 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xpath.c: Optimization of count(): eliminated sorting
......
......@@ -2141,6 +2141,7 @@ xmlXPathNodeSetCreate(xmlNodePtr val) {
return(ret);
}
#if 0 /* enable if needed */
/**
* xmlXPathNodeSetCreateSize:
* @val: an initial xmlNodePtr, or NULL
......@@ -2175,6 +2176,7 @@ xmlXPathNodeSetCreateSize(int size)
}
return(ret);
}
#endif
/**
* xmlXPathNodeSetContains:
......@@ -2399,14 +2401,22 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
if (val2 == NULL) return(val1);
if (val1 == NULL) {
/*
* Optimization: Create an equally sized node-set
* and memcpy the content.
*/
val1 = xmlXPathNodeSetCreateSize(val2->nodeNr);
if (val1 == NULL)
return(NULL);
if (val2->nodeNr != 0) {
val1 = xmlXPathNodeSetCreate(NULL);
#if 0
/*
* TODO: The optimization won't work in every case, since
* those nasty namespace nodes need to be added with
* xmlXPathNodeSetDupNs() to the set; thus a pure
* memcpy is not possible.
*/
/*
* Optimization: Create an equally sized node-set
* and memcpy the content.
*/
val1 = xmlXPathNodeSetCreateSize(val2->nodeNr);
if (val1 == NULL)
return(NULL);
if (val2->nodeNr != 0) {
if (val2->nodeNr == 1)
*(val1->nodeTab) = *(val2->nodeTab);
else {
......@@ -2414,8 +2424,9 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
val2->nodeNr * sizeof(xmlNodePtr));
}
val1->nodeNr = val2->nodeNr;
}
}
return(val1);
#endif /* if 0 */
}
/* @@ with_ns to check whether namespace nodes should be looked at @@ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment