mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-01-27 05:23:51 +00:00
speedup some node selection operations, this can have a significant impact
* xpath.c: speedup some node selection operations, this can have a significant impact on DocBook Norm's stylesheets * nanohttp.c: someone reported that SOCKLEN_T may not be defined make sure it's always the case * debugXML.c: distinguish CDATA and comments in ls operations Daniel
This commit is contained in:
parent
61f261749f
commit
75be013085
@ -1,3 +1,11 @@
|
||||
Wed Mar 13 11:00:59 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xpath.c: speedup some node selection operations, this can
|
||||
have a significant impact on DocBook Norm's stylesheets
|
||||
* nanohttp.c: someone reported that SOCKLEN_T may not be defined
|
||||
make sure it's always the case
|
||||
* debugXML.c: distinguish CDATA and comments in ls operations
|
||||
|
||||
Tue Mar 12 19:45:24 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* include/libxml/*.h: Heiko W. Rupp fixed a lot of comments
|
||||
|
@ -1148,7 +1148,7 @@ xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
||||
fprintf(output, "t");
|
||||
break;
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
fprintf(output, "c");
|
||||
fprintf(output, "C");
|
||||
break;
|
||||
case XML_ENTITY_REF_NODE:
|
||||
fprintf(output, "e");
|
||||
|
@ -78,6 +78,12 @@
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
#ifndef SOCKLEN_T
|
||||
#define SOCKLEN_T unsigned int
|
||||
#endif
|
||||
#ifndef SOCKET
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
#ifdef STANDALONE
|
||||
#define DEBUG_HTTP
|
||||
|
72
xpath.c
72
xpath.c
@ -1772,6 +1772,68 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
|
||||
return(val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXPathNodeSetMergeUnique:
|
||||
* @val1: the first NodeSet or NULL
|
||||
* @val2: the second NodeSet
|
||||
*
|
||||
* Merges two nodesets, all nodes from @val2 are added to @val1
|
||||
* if @val1 is NULL, a new set is created and copied from @val2
|
||||
*
|
||||
* Returns @val1 once extended or NULL in case of error.
|
||||
*/
|
||||
static xmlNodeSetPtr
|
||||
xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
|
||||
int i, initNr;
|
||||
|
||||
if (val2 == NULL) return(val1);
|
||||
if (val1 == NULL) {
|
||||
val1 = xmlXPathNodeSetCreate(NULL);
|
||||
}
|
||||
|
||||
/* @@ with_ns to check wether namespace nodes should be looked at @@ */
|
||||
initNr = val1->nodeNr;
|
||||
|
||||
for (i = 0;i < val2->nodeNr;i++) {
|
||||
/*
|
||||
* grow the nodeTab if needed
|
||||
*/
|
||||
if (val1->nodeMax == 0) {
|
||||
val1->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
|
||||
sizeof(xmlNodePtr));
|
||||
if (val1->nodeTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlXPathNodeSetMerge: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(val1->nodeTab, 0 ,
|
||||
XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
|
||||
val1->nodeMax = XML_NODESET_DEFAULT;
|
||||
} else if (val1->nodeNr == val1->nodeMax) {
|
||||
xmlNodePtr *temp;
|
||||
|
||||
val1->nodeMax *= 2;
|
||||
temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax *
|
||||
sizeof(xmlNodePtr));
|
||||
if (temp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlXPathNodeSetMerge: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
val1->nodeTab = temp;
|
||||
}
|
||||
if (val2->nodeTab[i]->type == XML_NAMESPACE_DECL) {
|
||||
xmlNsPtr ns = (xmlNsPtr) val2->nodeTab[i];
|
||||
|
||||
val1->nodeTab[val1->nodeNr++] =
|
||||
xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
|
||||
} else
|
||||
val1->nodeTab[val1->nodeNr++] = val2->nodeTab[i];
|
||||
}
|
||||
|
||||
return(val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXPathNodeSetDel:
|
||||
* @cur: the initial node set
|
||||
@ -8233,6 +8295,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
xmlNodeSetPtr ret, list;
|
||||
xmlXPathTraversalFunction next = NULL;
|
||||
void (*addNode) (xmlNodeSetPtr, xmlNodePtr);
|
||||
xmlNodeSetPtr (*mergeNodeSet) (xmlNodeSetPtr, xmlNodeSetPtr);
|
||||
xmlNodePtr cur = NULL;
|
||||
xmlXPathObjectPtr obj;
|
||||
xmlNodeSetPtr nodelist;
|
||||
@ -8241,6 +8304,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
CHECK_TYPE0(XPATH_NODESET);
|
||||
obj = valuePop(ctxt);
|
||||
addNode = xmlXPathNodeSetAdd;
|
||||
mergeNodeSet = xmlXPathNodeSetMerge;
|
||||
if (prefix != NULL) {
|
||||
URI = xmlXPathNsLookup(ctxt->context, prefix);
|
||||
if (URI == NULL)
|
||||
@ -8272,6 +8336,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
next = xmlXPathNextAttribute;
|
||||
mergeNodeSet = xmlXPathNodeSetMergeUnique;
|
||||
break;
|
||||
case AXIS_CHILD:
|
||||
#ifdef DEBUG_STEP
|
||||
@ -8279,6 +8344,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
#endif
|
||||
last = NULL;
|
||||
next = xmlXPathNextChild;
|
||||
mergeNodeSet = xmlXPathNodeSetMergeUnique;
|
||||
break;
|
||||
case AXIS_DESCENDANT:
|
||||
#ifdef DEBUG_STEP
|
||||
@ -8309,6 +8375,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
#endif
|
||||
last = NULL;
|
||||
next = xmlXPathNextFollowingSibling;
|
||||
mergeNodeSet = xmlXPathNodeSetMergeUnique;
|
||||
break;
|
||||
case AXIS_NAMESPACE:
|
||||
#ifdef DEBUG_STEP
|
||||
@ -8317,6 +8384,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
next = (xmlXPathTraversalFunction) xmlXPathNextNamespace;
|
||||
mergeNodeSet = xmlXPathNodeSetMergeUnique;
|
||||
break;
|
||||
case AXIS_PARENT:
|
||||
#ifdef DEBUG_STEP
|
||||
@ -8339,6 +8407,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
#endif
|
||||
first = NULL;
|
||||
next = xmlXPathNextPrecedingSibling;
|
||||
mergeNodeSet = xmlXPathNodeSetMergeUnique;
|
||||
break;
|
||||
case AXIS_SELF:
|
||||
#ifdef DEBUG_STEP
|
||||
@ -8347,6 +8416,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
next = xmlXPathNextSelf;
|
||||
mergeNodeSet = xmlXPathNodeSetMergeUnique;
|
||||
break;
|
||||
}
|
||||
if (next == NULL)
|
||||
@ -8591,7 +8661,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
||||
if (ret == NULL) {
|
||||
ret = list;
|
||||
} else {
|
||||
ret = xmlXPathNodeSetMerge(ret, list);
|
||||
ret = mergeNodeSet(ret, list);
|
||||
xmlXPathFreeNodeSet(list);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user