[no subject]
They give up to 20% performance increase in cases I'm
interested in, on a moderately slow system (PII-350),
somewhat less on a P3-1000 and -I hope- somewhat
more on the 100MHz PC104 boards.
See measurement results below.
The diffs are attached (zipped and plain). They consist of:
- name ownership taking versions of xmlNewNode,
xmlNewDocNode and xmlNewNsProp. The original
versions are unchanged, but to clean up, in an exchange
for one extra function call, the original versions may
better be implemented as in
xmlNewNode(...name..) {
return xmlNewNodeEatName(...xmlStrdup(name)...);
}
- disinlining all but the first line of SHRINK and GROW
- specialised function xmlParseNameAndCompare
for endtag parsing, which can avoid one malloc and some
processing in all but the nonWF-error case.
Regards,
Peter Jacobi
Benchmarks done using statically linked xmllint, all options disabled.
api.xml [500k] : the libxml-api.xml file from 2.4.22
api-e.xml [592k] : that file, with all attributes XSLT transformed into
elements
nethb.xml [75k] : biomed amplifier status file
nethb-e.xml [98k] : that file, with all attributes XSLT transformed into
elements
td.xml [489k]: save file from a board game design app
xmllint --noout --timing --repeat
numbers are ms / iteration
WinNT 4 SP5 Pentium II 350 MHz Watcom C/C++ 11.0b
Base Patched
api.xml 349 300
api-e.xml 290 229
nethb.xml 68 58
nethb-e.xml 66 52
td.xml 275 229
Win2000 SP1 Pentium III 1000 MHz Watcom C/C++ 11.0b
Base Patched
api.xml 120 108
api-e.xml 102 85
nethb.xml 23 21
nethb-e.xml 23 19
td.xml 96 84
--Message-Boundary-28614
Content-type: Application/ZIP; name="ppatch-diffs.zip"
Content-disposition: attachment; filename="ppatch-diffs.zip"
Content-transfer-encoding: BASE64
UEsDBBQAAgAIAAOtvCz4AkCX9gQAAB0TAAANAAAAcGFyc2VyLmMuZGlmZtVWe0/bSBD/25X6
HSac2tpJTBLnAYQCTbkUIkiKCKhIxyky9oZYOE7Ojytcm+9+M7trxw4JB21ReysBZnbeM7+Z
zefzsL5+aeg13TAup6YfMH/dUj74DnTNO6iUoVxrVuvNSg2Mctl4+ULXdUjYziLG2YxNMCpN
w2gadcmWzx5OQLZK0djaBEEBUADP7dg9mUw73jQK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ELfCUIKBwTHIkI9
D/TeHY8ALFygGdb1k5JQ1s4RTURZKzxbZUyCXbINN59uWdHw65vxaILYUimp51k4mO/0bCmq
O6bWeoR1haBIecunvw72nNLRQwcKJmcUAGxFnlpIfq9tQ+6HvFZWy9wpg6SRhlpD3fBWK1Ht
j8Wf11FMvnHlGNKg3sKhfthLg/rEoSS8fBr6V/FSfeXRCezyuBUJAv1ANISMqUguFUdPApyU
8Mx2iP2k/x8fToho6Q8B/orHYOd3L895ZlCzyvIiHb6nikmt/o+WfABQSwECFgsUAAIACAAD
rbws+AJAl/YEAAAdEwAADQAAAAAAAAABACAAtoEAAAAAcGFyc2VyLmMuZGlmZlBLAQIWCxQA
AgAIAPWsvCwkue3D/QEAAFIGAAAKAAAAAAAAAAEAIAC2gSEFAABzYXguYy5kaWZmUEsBAhYL
FAACAAgA+6y8LOjx9RQsBQAAmxEAAAsAAAAAAAAAAQAgALaBRgcAAHRyZWUuYy5kaWZmUEsB
AhYLFAACAAgAD628LK4DCSpRAQAAhAQAAAsAAAAAAAAAAQAgALaBmwwAAHRyZWUuaC5kaWZm
UEsFBgAAAAAEAAQA5QAAABUOAAAAAA==
--Message-Boundary-28614
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'sax.c.diff'
*** ..\2-4-22\sax.c Mon Mar 25 16:50:04 2002
--- sax.c Tue May 28 20:42:08 2002
***************
*** 907,913 ****
}
/* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */
! ret = xmlNewNsProp(ctxt->node, namespace, name, NULL);
if (ret != NULL) {
if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
--- 907,913 ----
}
/* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */
! ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL);
if (ret != NULL) {
if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
***************
*** 984,991 ****
if (nval != NULL)
xmlFree(nval);
- if (name != NULL)
- xmlFree(name);
if (ns != NULL)
xmlFree(ns);
}
--- 984,989 ----
***************
*** 1194,1200 ****
* attributes parsing, since local namespace can be defined as
* an attribute at this level.
*/
! ret = xmlNewDocNode(ctxt->myDoc, NULL, name, NULL);
if (ret == NULL) return;
if (ctxt->myDoc->children == NULL) {
#ifdef DEBUG_SAX_TREE
--- 1192,1198 ----
* attributes parsing, since local namespace can be defined as
* an attribute at this level.
*/
! ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, name, NULL);
if (ret == NULL) return;
if (ctxt->myDoc->children == NULL) {
#ifdef DEBUG_SAX_TREE
***************
*** 1334,1341 ****
if (prefix != NULL)
xmlFree(prefix);
- if (name != NULL)
- xmlFree(name);
}
--- 1332,1337 ----
--Message-Boundary-28614
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'parser.c.diff'
*** ..\2-4-22\parser.c Fri May 10 04:35:14 2002
--- parser.c Tue May 28 21:22:25 2002
***************
*** 281,298 ****
xmlPopInput(ctxt); \
} while (0)
! #define SHRINK if (ctxt->input->cur - ctxt->input->base > INPUT_CHUNK) {\
! xmlParserInputShrink(ctxt->input); \
! if ((*ctxt->input->cur == 0) && \
! (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) \
! xmlPopInput(ctxt); \
}
! #define GROW if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK) { \
! xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
! if ((*ctxt->input->cur == 0) && \
! (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) \
! xmlPopInput(ctxt); \
}
#define SKIP_BLANKS xmlSkipBlankChars(ctxt)
--- 281,304 ----
xmlPopInput(ctxt); \
} while (0)
! #define SHRINK if (ctxt->input->cur - ctxt->input->base > INPUT_CHUNK) \
! xmlSHRINK (ctxt);
!
! static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
! xmlParserInputShrink(ctxt->input);
! if ((*ctxt->input->cur == 0) &&
! (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
! xmlPopInput(ctxt);
}
! #define GROW if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK) \
! xmlGROW (ctxt);
!
! static void xmlGROW (xmlParserCtxtPtr ctxt) {
! xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
! if ((*ctxt->input->cur == 0) &&
! (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
! xmlPopInput(ctxt);
}
#define SKIP_BLANKS xmlSkipBlankChars(ctxt)
***************
*** 1746,1751 ****
--- 1752,1793 ----
return(xmlParseNameComplex(ctxt));
}
+ /**
+ * xmlParseNameAndCompare:
+ * @ctxt: an XML parser context
+ *
+ * parse an XML name and compares for match
+ * (specialized for endtag parsing)
+ *
+ *
+ * Returns NULL for an illegal name, (xmlChar*) 1 for success
+ * and the name for mismatch
+ */
+
+ xmlChar *
+ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) {
+ const xmlChar *cmp = other;
+ const xmlChar *in;
+ xmlChar *ret;
+ int count = 0;
+
+ GROW;
+
+ in = ctxt->input->cur;
+ while (*in != 0 && *in == *cmp) {
+ ++in;
+ ++cmp;
+ }
+ if (*cmp == 0 && (*in == '>' || IS_BLANK (*in))) {
+ /* success */
+ ctxt->input->cur = in;
+ return (xmlChar*) 1;
+ }
+ /* failure, decide why */
+ ret = xmlParseName (ctxt);
+ return ret;
+ }
+
static xmlChar *
xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
xmlChar buf[XML_MAX_NAMELEN + 5];
***************
*** 6556,6562 ****
}
SKIP(2);
! name = xmlParseName(ctxt);
/*
* We should definitely be at the ending "S? '>'" part
--- 6598,6604 ----
}
SKIP(2);
! name = xmlParseNameAndCompare(ctxt,ctxt->name);
/*
* We should definitely be at the ending "S? '>'" part
***************
*** 6578,6597 ****
* start-tag.
*
*/
! if ((name == NULL) || (ctxt->name == NULL) ||
! (!xmlStrEqual(name, ctxt->name))) {
ctxt->errNo = XML_ERR_TAG_NAME_MISMATCH;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) {
! if ((name != NULL) && (ctxt->name != NULL)) {
ctxt->sax->error(ctxt->userData,
"Opening and ending tag mismatch: %s and %s\n",
ctxt->name, name);
! } else if (ctxt->name != NULL) {
ctxt->sax->error(ctxt->userData,
"Ending tag error for: %s\n", ctxt->name);
- } else {
- ctxt->sax->error(ctxt->userData,
- "Ending tag error: internal error ???\n");
}
}
--- 6620,6636 ----
* start-tag.
*
*/
! if (name != (xmlChar*)1) {
ctxt->errNo = XML_ERR_TAG_NAME_MISMATCH;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) {
! if (name != NULL) {
ctxt->sax->error(ctxt->userData,
"Opening and ending tag mismatch: %s and %s\n",
ctxt->name, name);
! xmlFree(name);
! } else {
ctxt->sax->error(ctxt->userData,
"Ending tag error for: %s\n", ctxt->name);
}
}
***************
*** 6604,6613 ****
*/
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL) &&
(!ctxt->disableSAX))
! ctxt->sax->endElement(ctxt->userData, name);
- if (name != NULL)
- xmlFree(name);
oldname = namePop(ctxt);
spacePop(ctxt);
if (oldname != NULL) {
--- 6643,6650 ----
*/
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL) &&
(!ctxt->disableSAX))
! ctxt->sax->endElement(ctxt->userData, ctxt->name);
oldname = namePop(ctxt);
spacePop(ctxt);
if (oldname != NULL) {
--Message-Boundary-28614
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'tree.c.diff'
*** ..\2-4-22\tree.c Sat May 25 04:35:18 2002
--- tree.c Tue May 28 20:40:36 2002
***************
*** 1204,1209 ****
--- 1204,1286 ----
}
/**
+ * xmlNewNsPropEatName:
+ * @node: the holding node
+ * @ns: the namespace
+ * @name: the name of the attribute
+ * @value: the value of the attribute
+ *
+ * Create a new property tagged with a namespace and carried by a node.
+ * Returns a pointer to the attribute
+ */
+ xmlAttrPtr
+ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
+ const xmlChar *value) {
+ xmlAttrPtr cur;
+ xmlDocPtr doc = NULL;
+
+ if (name == NULL) {
+ #ifdef DEBUG_TREE
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlNewNsPropEatName : name == NULL\n");
+ #endif
+ return(NULL);
+ }
+
+ /*
+ * Allocate a new property and fill the fields.
+ */
+ cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
+ if (cur == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlNewNsPropEatName : malloc failed\n");
+ return(NULL);
+ }
+ memset(cur, 0, sizeof(xmlAttr));
+ cur->type = XML_ATTRIBUTE_NODE;
+
+ cur->parent = node;
+ if (node != NULL) {
+ doc = node->doc;
+ cur->doc = doc;
+ }
+ cur->ns = ns;
+ cur->name = name;
+ if (value != NULL) {
+ xmlChar *buffer;
+ xmlNodePtr tmp;
+
+ buffer = xmlEncodeEntitiesReentrant(doc, value);
+ cur->children = xmlStringGetNodeList(doc, buffer);
+ cur->last = NULL;
+ tmp = cur->children;
+ while (tmp != NULL) {
+ tmp->parent = (xmlNodePtr) cur;
+ if (tmp->next == NULL)
+ cur->last = tmp;
+ tmp = tmp->next;
+ }
+ xmlFree(buffer);
+ }
+
+ /*
+ * Add it at the end to preserve parsing order ...
+ */
+ if (node != NULL) {
+ if (node->properties == NULL) {
+ node->properties = cur;
+ } else {
+ xmlAttrPtr prev = node->properties;
+
+ while (prev->next != NULL) prev = prev->next;
+ prev->next = cur;
+ cur->prev = prev;
+ }
+ }
+ return(cur);
+ }
+
+ /**
* xmlNewDocProp:
* @doc: the document
* @name: the name of the attribute
***************
*** 1432,1437 ****
--- 1509,1552 ----
}
/**
+ * xmlNewNodeEatName:
+ * @ns: namespace if any
+ * @name: the node name
+ *
+ * Creation of a new node element. @ns is optional (NULL).
+ *
+ * Returns a pointer to the new node object.
+ */
+ xmlNodePtr
+ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
+ xmlNodePtr cur;
+
+ if (name == NULL) {
+ #ifdef DEBUG_TREE
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlNewNode : name == NULL\n");
+ #endif
+ return(NULL);
+ }
+
+ /*
+ * Allocate a new node and fill the fields.
+ */
+ cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
+ if (cur == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlNewNode : malloc failed\n");
+ return(NULL);
+ }
+ memset(cur, 0, sizeof(xmlNode));
+ cur->type = XML_ELEMENT_NODE;
+
+ cur->name = name;
+ cur->ns = ns;
+ return(cur);
+ }
+
+ /**
* xmlNewDocNode:
* @doc: the document
* @ns: namespace if any
***************
*** 1453,1458 ****
--- 1568,1605 ----
xmlNodePtr cur;
cur = xmlNewNode(ns, name);
+ if (cur != NULL) {
+ cur->doc = doc;
+ if (content != NULL) {
+ cur->children = xmlStringGetNodeList(doc, content);
+ UPDATE_LAST_CHILD_AND_PARENT(cur)
+ }
+ }
+ return(cur);
+ }
+
+ /**
+ * xmlNewDocNodeEatName:
+ * @doc: the document
+ * @ns: namespace if any
+ * @name: the node name
+ * @content: the XML text content if any
+ *
+ * Creation of a new node element within a document. @ns and @content
+ * are optional (NULL).
+ * NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities
+ * references, but XML special chars need to be escaped first by using
+ * xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't
+ * need entities support.
+ *
+ * Returns a pointer to the new node object.
+ */
+ xmlNodePtr
+ xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
+ xmlChar *name, const xmlChar *content) {
+ xmlNodePtr cur;
+
+ cur = xmlNewNodeEatName(ns, name);
if (cur != NULL) {
cur->doc = doc;
if (content != NULL) {
--Message-Boundary-28614
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'tree.h.diff'
*** ..\2-4-22\include\libxml\tree.h Thu Apr 18 04:35:16 2002
--- include\libxml\tree.h Tue May 28 20:32:23 2002
***************
*** 591,596 ****
--- 591,600 ----
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *value);
+ xmlAttrPtr xmlNewNsPropEatName (xmlNodePtr node,
+ xmlNsPtr ns,
+ xmlChar *name,
+ const xmlChar *value);
void xmlFreePropList (xmlAttrPtr cur);
void xmlFreeProp (xmlAttrPtr cur);
xmlAttrPtr xmlCopyProp (xmlNodePtr target,
***************
*** 608,619 ****
--- 612,629 ----
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
+ xmlNodePtr xmlNewDocNodeEatName (xmlDocPtr doc,
+ xmlNsPtr ns,
+ xmlChar *name,
+ const xmlChar *content);
xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
xmlNodePtr xmlNewNode (xmlNsPtr ns,
const xmlChar *name);
+ xmlNodePtr xmlNewNodeEatName (xmlNsPtr ns,
+ xmlChar *name);
xmlNodePtr xmlNewChild (xmlNodePtr parent,
xmlNsPtr ns,
const xmlChar *name,
--Message-Boundary-28614--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]