Old but effective optimization patch:
- parser.c parserInternals.c: applied Bjorn Reese optimization patch
Daniel
diff --git a/ChangeLog b/ChangeLog
index 41b7911..905bc3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sat Jan 6 22:05:09 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * parser.c parserInternals.c: applied Bjorn Reese optimization
+ patch
+
+Sat Jan 6 19:13:27 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * Makefile.am: applied patch fro make check from Martin Vidner
+
Thu Jan 4 19:07:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* configure.in: preparing 2.2.11
diff --git a/Makefile.am b/Makefile.am
index 1bd18c3..3c27f43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -95,14 +95,14 @@
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
echo New test file $$name ; \
- testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
+ $(top_builddir)/testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
else \
echo Testing $$name ; \
- testHTML $$i > result.$$name 2> error.$$name ; \
+ $(top_builddir)/testHTML $$i > result.$$name 2> error.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/HTML/$$name result.$$name ; \
diff -b $(srcdir)/result/HTML/$$name.err error.$$name ; \
- testHTML result.$$name > result2.$$name 2>error.$$name ; \
+ $(top_builddir)/testHTML result.$$name > result2.$$name 2>error.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name error.$$name ; \
fi ; fi ; done)
@@ -114,16 +114,16 @@
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
echo New test file $$name ; \
- testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
+ $(top_builddir)/testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
else \
echo Testing $$name ; \
- testHTML --push $$i > result.$$name 2> error.$$name ; \
+ $(top_builddir)/testHTML --push $$i > result.$$name 2> error.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/HTML/$$name result.$$name ; \
cut -b 1-15 $(srcdir)/result/HTML/$$name.err > errorcut.$$name; \
cut -b 1-15 error.$$name > errorcut2.$$name; \
diff -b errorcut.$$name errorcut2.$$name ; \
- testHTML --push result.$$name > result2.$$name 2>error.$$name ; \
+ $(top_builddir)/testHTML --push result.$$name > result2.$$name 2>error.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name error.$$name errorcut.$$name errorcut2.$$name ; \
fi ; fi ; done)
@@ -135,10 +135,10 @@
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/HTML/$$name.sax ] ; then \
echo New test file $$name ; \
- testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
+ $(top_builddir)/testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
else \
echo Testing $$name ; \
- testHTML --sax $$i > result.$$name.sax ; \
+ $(top_builddir)/testHTML --sax $$i > result.$$name.sax ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax ; \
rm result.$$name.sax ; \
@@ -151,10 +151,10 @@
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
echo New test file $$name ; \
- testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
+ $(top_builddir)/testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
else \
echo Testing $$name ; \
- testHTML --push --sax $$i > result.$$name.sax ; \
+ $(top_builddir)/testHTML --push --sax $$i > result.$$name.sax ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax ; \
rm result.$$name.sax ; \
@@ -162,6 +162,7 @@
XMLtests : xmllint
+ @(rm -f .memdump ; touch .memdump)
@echo "##"
@echo "## XML regression tests"
@echo "##"
@@ -199,6 +200,7 @@
fi ; fi ; done)
XMLenttests : xmllint
+ @(rm -f .memdump ; touch .memdump)
@echo "##"
@echo "## XML entity subst regression tests"
@echo "##"
diff --git a/parser.c b/parser.c
index f3f0565..bc880da 100644
--- a/parser.c
+++ b/parser.c
@@ -2092,75 +2092,77 @@
buf[len++] = *current++;
}
ctxt->token = 0;
- } else if ((c == '&') && (NXT(1) == '#')) {
- int val = xmlParseCharRef(ctxt);
- if (val == '&') {
- /*
- * The reparsing will be done in xmlStringGetNodeList()
- * called by the attribute() function in SAX.c
- */
- static xmlChar buffer[6] = "&";
-
- if (len > buf_size - 10) {
- growBuffer(buf);
- }
- current = &buffer[0];
- while (*current != 0) { /* non input consuming */
- buf[len++] = *current++;
- }
- } else {
- len += xmlCopyChar(0, &buf[len], val);
- }
} else if (c == '&') {
- ent = xmlParseEntityRef(ctxt);
- if ((ent != NULL) &&
- (ctxt->replaceEntities != 0)) {
- xmlChar *rep;
+ if (NXT(1) == '#') {
+ int val = xmlParseCharRef(ctxt);
+ if (val == '&') {
+ /*
+ * The reparsing will be done in xmlStringGetNodeList()
+ * called by the attribute() function in SAX.c
+ */
+ static xmlChar buffer[6] = "&";
- if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
- rep = xmlStringDecodeEntities(ctxt, ent->content,
- XML_SUBSTITUTE_REF, 0, 0, 0);
- if (rep != NULL) {
- current = rep;
- while (*current != 0) { /* non input consuming */
- buf[len++] = *current++;
- if (len > buf_size - 10) {
- growBuffer(buf);
- }
- }
- xmlFree(rep);
+ if (len > buf_size - 10) {
+ growBuffer(buf);
+ }
+ current = &buffer[0];
+ while (*current != 0) { /* non input consuming */
+ buf[len++] = *current++;
}
} else {
- if (ent->content != NULL)
- buf[len++] = ent->content[0];
+ len += xmlCopyChar(0, &buf[len], val);
}
- } else if (ent != NULL) {
- int i = xmlStrlen(ent->name);
- const xmlChar *cur = ent->name;
-
- /*
- * This may look absurd but is needed to detect
- * entities problems
- */
- if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
- (ent->content != NULL)) {
+ } else {
+ ent = xmlParseEntityRef(ctxt);
+ if ((ent != NULL) &&
+ (ctxt->replaceEntities != 0)) {
xmlChar *rep;
- rep = xmlStringDecodeEntities(ctxt, ent->content,
- XML_SUBSTITUTE_REF, 0, 0, 0);
- if (rep != NULL)
- xmlFree(rep);
- }
- /*
- * Just output the reference
- */
- buf[len++] = '&';
- if (len > buf_size - i - 10) {
- growBuffer(buf);
+ if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
+ rep = xmlStringDecodeEntities(ctxt, ent->content,
+ XML_SUBSTITUTE_REF, 0, 0, 0);
+ if (rep != NULL) {
+ current = rep;
+ while (*current != 0) { /* non input consuming */
+ buf[len++] = *current++;
+ if (len > buf_size - 10) {
+ growBuffer(buf);
+ }
+ }
+ xmlFree(rep);
+ }
+ } else {
+ if (ent->content != NULL)
+ buf[len++] = ent->content[0];
+ }
+ } else if (ent != NULL) {
+ int i = xmlStrlen(ent->name);
+ const xmlChar *cur = ent->name;
+
+ /*
+ * This may look absurd but is needed to detect
+ * entities problems
+ */
+ if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
+ (ent->content != NULL)) {
+ xmlChar *rep;
+ rep = xmlStringDecodeEntities(ctxt, ent->content,
+ XML_SUBSTITUTE_REF, 0, 0, 0);
+ if (rep != NULL)
+ xmlFree(rep);
+ }
+
+ /*
+ * Just output the reference
+ */
+ buf[len++] = '&';
+ if (len > buf_size - i - 10) {
+ growBuffer(buf);
+ }
+ for (;i > 0;i--)
+ buf[len++] = *cur++;
+ buf[len++] = ';';
}
- for (;i > 0;i--)
- buf[len++] = *cur++;
- buf[len++] = ';';
}
} else {
if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {
diff --git a/parserInternals.c b/parserInternals.c
index a20faf5..37e3c7b 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -428,15 +428,30 @@
*
* Returns 0 if not, non-zero otherwise
*/
+static int xmlBaseArray[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 - 0x000F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0010 - 0x001F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0020 - 0x002F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0030 - 0x003F */
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0040 - 0x004F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0050 - 0x005F */
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0060 - 0x006F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0070 - 0x007F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0080 - 0x008F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0090 - 0x009F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00A0 - 0x00AF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00B0 - 0x00BF */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00C0 - 0x00CF */
+ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00D0 - 0x00DF */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00E0 - 0x00EF */
+ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00F0 - 0x00FF */
+};
+
int
xmlIsBaseChar(int c) {
return(
- (((c) >= 0x0041) && ((c) <= 0x005A)) ||
- (((c) >= 0x0061) && ((c) <= 0x007A)) ||
- (((c) >= 0x00C0) && ((c) <= 0x00D6)) ||
- (((c) >= 0x00D8) && ((c) <= 0x00F6)) ||
- (((c) >= 0x00F8) && ((c) <= 0x00FF)) ||
- (((c) >= 0x100) && ( /* accelerator */
+ (((c) < 0x0100) ? xmlBaseArray[c] :
+ ( /* accelerator */
(((c) >= 0x0100) && ((c) <= 0x0131)) ||
(((c) >= 0x0134) && ((c) <= 0x013E)) ||
(((c) >= 0x0141) && ((c) <= 0x0148)) ||
@@ -794,13 +809,16 @@
*/
int
xmlIsExtender(int c) {
- return(
- ((c) == 0xb7) || ((c) == 0x2d0) || ((c) == 0x2d1) ||
- ((c) == 0x387) || ((c) == 0x640) || ((c) == 0xe46) ||
- ((c) == 0xec6) || ((c) == 0x3005) ||
- (((c) >= 0x3031) && ((c) <= 0x3035)) ||
- (((c) >= 0x309b) && ((c) <= 0x309e)) ||
- (((c) >= 0x30fc) && ((c) <= 0x30fe)));
+ switch (c) {
+ case 0x00B7: case 0x02D0: case 0x02D1: case 0x0387:
+ case 0x0640: case 0x0E46: case 0x0EC6: case 0x3005:
+ case 0x3031: case 0x3032: case 0x3033: case 0x3034:
+ case 0x3035: case 0x309D: case 0x309E: case 0x30FC:
+ case 0x30FE:
+ return 1;
+ default:
+ return 0;
+ }
}
/**
@@ -814,7 +832,7 @@
*/
int
xmlIsIdeographic(int c) {
- return(
+ return(((c) < 0x0100) ? 0 :
(((c) >= 0x4e00) && ((c) <= 0x9fa5)) ||
(((c) >= 0xf900) && ((c) <= 0xfa2d)) ||
(((c) >= 0x3021) && ((c) <= 0x3029)) ||