Permalink
Browse files

starting work on reusing the parser dictionary for the element and

* SAX2.c include/libxml/parser.h: starting work on reusing the
  parser dictionary for the element and attribute tag names.
  Add pools for Element and Attributes in the parser context,
  which should help speeding up the reader.
* Makefile.am result/*.rdr : adding non-python reader regression
  tests.
Daniel
  • Loading branch information...
1 parent 62998c0 commit 8a44e59d67bdff87e3e28851ce780f33425407f8 Daniel Veillard committed Sep 15, 2003
Showing with 36,626 additions and 27 deletions.
  1. +9 −0 ChangeLog
  2. +22 −1 Makefile.am
  3. +79 −26 SAX2.c
  4. +7 −0 include/libxml/parser.h
  5. +1 −0 result/att1.rdr
  6. +1 −0 result/att2.rdr
  7. +3 −0 result/att3.rdr
  8. +27,785 −0 result/att4.rdr
  9. +109 −0 result/att5.rdr
  10. +1 −0 result/attrib.xml.rdr
  11. +4 −0 result/bigentname.xml.rdr
  12. +1 −0 result/bigname.xml.rdr
  13. +1 −0 result/bigname2.xml.rdr
  14. +7 −0 result/cdata.rdr
  15. +13 −0 result/comment.xml.rdr
  16. +9 −0 result/comment2.xml.rdr
  17. +78 −0 result/dav1.rdr
  18. +9 −0 result/dav10.rdr
  19. +60 −0 result/dav11.rdr
  20. +3 −0 result/dav12.rdr
  21. +45 −0 result/dav13.rdr
  22. +73 −0 result/dav15.rdr
  23. +13 −0 result/dav16.rdr
  24. +75 −0 result/dav17.rdr
  25. +13 −0 result/dav18.rdr
  26. +59 −0 result/dav19.rdr
  27. +81 −0 result/dav2.rdr
  28. +57 −0 result/dav3.rdr
  29. +47 −0 result/dav4.rdr
  30. +50 −0 result/dav5.rdr
  31. +63 −0 result/dav6.rdr
  32. +57 −0 result/dav7.rdr
  33. +51 −0 result/dav8.rdr
  34. +67 −0 result/dav9.rdr
  35. +2 −0 result/defattr.xml.rdr
  36. +2 −0 result/defattr2.xml.rdr
  37. +292 −0 result/dia1.rdr
  38. +292 −0 result/dia2.rdr
  39. +5 −0 result/dtd1.rdr
  40. +12 −0 result/dtd10.rdr
  41. +3 −0 result/dtd11.rdr
  42. +4 −0 result/dtd12.rdr
  43. +4 −0 result/dtd13.rdr
  44. +4 −0 result/dtd2.rdr
  45. +4 −0 result/dtd3.rdr
  46. +2 −0 result/dtd4.rdr
  47. +11 −0 result/dtd5.rdr
  48. +12 −0 result/dtd6.rdr
  49. +9 −0 result/dtd7.rdr
  50. +9 −0 result/dtd8.rdr
  51. +9 −0 result/dtd9.rdr
  52. +8 −0 result/ent1.rdr
  53. +13 −0 result/ent2.rdr
  54. +6 −0 result/ent3.rdr
  55. +6 −0 result/ent4.rdr
  56. +6 −0 result/ent5.rdr
  57. +3 −0 result/ent6.rdr
  58. +8 −0 result/ent7.rdr
  59. +21 −0 result/ent8.rdr
  60. +5 −0 result/eve.xml.rdr
  61. +3 −0 result/isolat1.rdr
  62. +108 −0 result/isolat2.rdr
  63. +23 −0 result/isolat3.rdr
  64. +7 −0 result/ns.rdr
  65. +1 −0 result/ns2.rdr
  66. +1 −0 result/ns3.rdr
  67. +1 −0 result/ns4.rdr
  68. +55 −0 result/p3p.rdr
  69. +13 −0 result/pi.xml.rdr
  70. +9 −0 result/pi2.xml.rdr
  71. +214 −0 result/rdf1.rdr
  72. +2,008 −0 result/rdf2.rdr
  73. +218 −0 result/slashdot.rdf.rdr
  74. +514 −0 result/slashdot.xml.rdr
  75. +718 −0 result/slashdot16.xml.rdr
  76. +477 −0 result/svg1.rdr
  77. +178 −0 result/svg2.rdr
  78. +2,164 −0 result/svg3.rdr
  79. +3 −0 result/title.xml.rdr
  80. +3 −0 result/tstblanks.xml.rdr
  81. +3 −0 result/utf16bom.xml.rdr
  82. +1 −0 result/utf8bom.xml.rdr
  83. +70 −0 result/wap.xml.rdr
  84. +24 −0 result/wml.xml.rdr
  85. +95 −0 result/xhtml1.rdr
  86. +4 −0 result/xml1.rdr
  87. +6 −0 result/xml2.rdr
View
@@ -1,3 +1,12 @@
+Mon Sep 15 16:46:28 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+ * SAX2.c include/libxml/parser.h: starting work on reusing the
+ parser dictionary for the element and attribute tag names.
+ Add pools for Element and Attributes in the parser context,
+ which should help speeding up the reader.
+ * Makefile.am result/*.rdr : adding non-python reader regression
+ tests.
+
Mon Sep 15 14:54:42 CEST 2003 Daniel Veillard <daniel@veillard.com>
* SAX2.c parser.c valid.c: starting to cleanup some of the
View
@@ -120,7 +120,7 @@ check-local: tests
testall : tests SVGtests SAXtests
-tests: XMLtests XMLenttests NStests SAXtests HTMLtests Validtests URItests XPathtests XPtrtests XIncludetests C14Ntests Scripttests Catatests @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@
+tests: XMLtests XMLenttests NStests Readertests SAXtests HTMLtests Validtests URItests XPathtests XPtrtests XIncludetests C14Ntests Scripttests Catatests @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; $(MAKE) tests ; fi)
valgrind:
@@ -569,6 +569,27 @@ Threadtests : testThreads$(EXEEXT)
-@($(CHECKER) $(top_builddir)/testThreads ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";)
+Readertests : testReader$(EXEEXT)
+ @(echo > .memdump)
+ @echo "##"
+ @echo "## Reader regression tests"
+ @echo "##"
+ -@(for i in $(srcdir)/test/* ; do \
+ name=`basename $$i`; \
+ if [ ! -d $$i ] ; then \
+ if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \
+ echo New test file $$name ; \
+ $(CHECKER) $(top_builddir)/xmllint --nonet --debug --stream $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
+ else \
+ echo Testing $$name ; \
+ $(CHECKER) $(top_builddir)/xmllint --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \
+ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
+ diff $(srcdir)/result/$$name.rdr result.$$name ; \
+ rm result.$$name ; \
+ fi ; fi ; done)
+
+
SAXtests : testSAX$(EXEEXT)
@(echo > .memdump)
@echo "##"
View
@@ -1624,28 +1624,58 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
if (prefix != NULL)
namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
- ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
-
- if (ret != NULL) {
- if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
- xmlNodePtr tmp;
+ /*
+ * allocate the node
+ */
+ if (ctxt->freeAttrs != NULL) {
+ ret = ctxt->freeAttrs;
+ ctxt->freeAttrs = ret->next;
+ memset(ret, 0, sizeof(xmlAttr));
+ ret->type = XML_ATTRIBUTE_NODE;
+
+ ret->parent = ctxt->node;
+ ret->doc = ctxt->myDoc;
+ ret->ns = namespace;
+
+ if (ctxt->dictNames)
+ ret->name = localname;
+ else
+ ret->name = xmlStrdup(localname);
+
+ if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
+ xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
+ } else {
+ if (ctxt->dictNames)
+ ret = xmlNewNsPropEatName(ctxt->node, namespace,
+ (xmlChar *) localname, NULL);
+ else
+ ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
+ if (ret == NULL) {
+ ctxt->errNo = XML_ERR_NO_MEMORY;
+ ctxt->instate = XML_PARSER_EOF;
+ ctxt->disableSAX = 1;
+ return;
+ }
+ }
- ret->children = xmlStringLenGetNodeList(ctxt->myDoc, value,
- valueend - value);
- tmp = ret->children;
- while (tmp != NULL) {
- tmp->parent = (xmlNodePtr) ret;
- if (tmp->next == NULL)
- ret->last = tmp;
- tmp = tmp->next;
- }
- } else if (value != NULL) {
- ret->children = xmlNewDocTextLen(ctxt->myDoc, value,
- valueend - value);
- ret->last = ret->children;
- if (ret->children != NULL)
- ret->children->parent = (xmlNodePtr) ret;
+ if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
+ xmlNodePtr tmp;
+
+ ret->children = xmlStringLenGetNodeList(ctxt->myDoc, value,
+ valueend - value);
+ tmp = ret->children;
+ while (tmp != NULL) {
+ tmp->parent = (xmlNodePtr) ret;
+ if (tmp->next == NULL)
+ ret->last = tmp;
+ tmp = tmp->next;
}
+ } else if (value != NULL) {
+ ret->children = xmlNewDocTextLen(ctxt->myDoc, value,
+ valueend - value);
+ ret->last = ret->children;
+ if (ret->children != NULL)
+ ret->children->parent = (xmlNodePtr) ret;
}
if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
@@ -1790,13 +1820,36 @@ xmlSAX2StartElementNs(void *ctx,
ctxt->errNo = XML_ERR_NO_DTD;
}
- ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
- if (ret == NULL) {
- ctxt->errNo = XML_ERR_NO_MEMORY;
- ctxt->instate = XML_PARSER_EOF;
- ctxt->disableSAX = 1;
- return;
+ /*
+ * allocate the node
+ */
+ if (ctxt->freeElems != NULL) {
+ ret = ctxt->freeElems;
+ ctxt->freeElems = ret->next;
+ memset(ret, 0, sizeof(xmlNode));
+ ret->type = XML_ELEMENT_NODE;
+
+ if (ctxt->dictNames)
+ ret->name = localname;
+ else
+ ret->name = xmlStrdup(localname);
+
+ if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
+ xmlRegisterNodeDefaultValue(ret);
+ } else {
+ if (ctxt->dictNames)
+ ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
+ (xmlChar *) localname, NULL);
+ else
+ ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
+ if (ret == NULL) {
+ ctxt->errNo = XML_ERR_NO_MEMORY;
+ ctxt->instate = XML_PARSER_EOF;
+ ctxt->disableSAX = 1;
+ return;
+ }
}
+
if (ctxt->myDoc->children == NULL) {
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
} else if (parent == NULL) {
@@ -262,6 +262,13 @@ struct _xmlParserCtxt {
xmlHashTablePtr attsDefault; /* defaulted attributes if any */
xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
int nsWellFormed; /* is the document XML Nanespace okay */
+
+ /*
+ * Those fields are needed only for treaming parsing so far
+ */
+ int dictNames; /* Use dictionary names for the tree */
+ xmlNodePtr freeElems; /* List of freed element nodes */
+ xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
};
/**
View
@@ -0,0 +1 @@
+0 1 doc 1 0
View
@@ -0,0 +1 @@
+0 1 doc 1 0
View
@@ -0,0 +1,3 @@
+0 1 select 0 0
+1 3 #text 0 1 f oo
+0 15 select 0 0
Oops, something went wrong.

0 comments on commit 8a44e59

Please sign in to comment.