1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-08 17:42:14 +03:00

- parser.c: more work on increasing parsing ferformances

Daniel
This commit is contained in:
Daniel Veillard
2001-02-25 19:54:14 +00:00
parent 48b2f8968e
commit 21a0f91852
2 changed files with 38 additions and 15 deletions

View File

@@ -1,3 +1,7 @@
Sun Feb 25 21:52:30 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* parser.c: more work on increasing parsing ferformances
Sun Feb 25 18:03:42 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sun Feb 25 18:03:42 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xmlmemory.h HTMLparser.c HTMLtree.c entities.c parser.c * xmlmemory.h HTMLparser.c HTMLtree.c entities.c parser.c

View File

@@ -75,7 +75,7 @@
#endif #endif
#define XML_PARSER_BIG_BUFFER_SIZE 1000 #define XML_PARSER_BIG_BUFFER_SIZE 300
#define XML_PARSER_BUFFER_SIZE 100 #define XML_PARSER_BUFFER_SIZE 100
/* /*
@@ -254,6 +254,13 @@ int spacePop(xmlParserCtxtPtr ctxt) {
#define NEXT xmlNextChar(ctxt) #define NEXT xmlNextChar(ctxt)
#define NEXT1 { \
ctxt->input->cur++; \
ctxt->nbChars++; \
if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
}
#define NEXTL(l) do { \ #define NEXTL(l) do { \
if (*(ctxt->input->cur) == '\n') { \ if (*(ctxt->input->cur) == '\n') { \
ctxt->input->line++; ctxt->input->col = 1; \ ctxt->input->line++; ctxt->input->col = 1; \
@@ -1589,6 +1596,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
* * * *
************************************************************************/ ************************************************************************/
xmlChar *xmlParseNameComplex(xmlParserCtxtPtr ctxt);
/** /**
* xmlParseName: * xmlParseName:
* @ctxt: an XML parser context * @ctxt: an XML parser context
@@ -1607,11 +1615,8 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
xmlChar * xmlChar *
xmlParseName(xmlParserCtxtPtr ctxt) { xmlParseName(xmlParserCtxtPtr ctxt) {
xmlChar buf[XML_MAX_NAMELEN + 5];
const xmlChar *in; const xmlChar *in;
xmlChar *ret; xmlChar *ret;
int len = 0, l;
int c;
int count = 0; int count = 0;
GROW; GROW;
@@ -1636,7 +1641,20 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
return(ret); return(ret);
} }
} }
xmlParseNameComplex(ctxt);
}
xmlChar *
xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
xmlChar buf[XML_MAX_NAMELEN + 5];
int len = 0, l;
int c;
int count = 0;
/*
* Handler for more complex cases
*/
GROW;
c = CUR_CHAR(l); c = CUR_CHAR(l);
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
(!IS_LETTER(c) && (c != '_') && (!IS_LETTER(c) && (c != '_') &&
@@ -5932,7 +5950,7 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
int i; int i;
if (RAW != '<') return(NULL); if (RAW != '<') return(NULL);
NEXT; NEXT1;
name = xmlParseName(ctxt); name = xmlParseName(ctxt);
if (name == NULL) { if (name == NULL) {
@@ -5953,9 +5971,9 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
SKIP_BLANKS; SKIP_BLANKS;
GROW; GROW;
while ((IS_CHAR(RAW)) && while ((RAW != '>') &&
(RAW != '>') && ((RAW != '/') || (NXT(1) != '>')) &&
((RAW != '/') || (NXT(1) != '>'))) { (IS_CHAR(RAW))) {
const xmlChar *q = CUR_PTR; const xmlChar *q = CUR_PTR;
int cons = ctxt->input->consumed; int cons = ctxt->input->consumed;
@@ -6097,7 +6115,7 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
ctxt->wellFormed = 0; ctxt->wellFormed = 0;
ctxt->disableSAX = 1; ctxt->disableSAX = 1;
} else } else
NEXT; NEXT1;
/* /*
* [ WFC: Element Type Match ] * [ WFC: Element Type Match ]
@@ -6276,6 +6294,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
const xmlChar *test = CUR_PTR; const xmlChar *test = CUR_PTR;
int cons = ctxt->input->consumed; int cons = ctxt->input->consumed;
xmlChar tok = ctxt->token; xmlChar tok = ctxt->token;
const xmlChar *cur = ctxt->input->cur;
/* /*
* Handle possible processed charrefs. * Handle possible processed charrefs.
@@ -6286,14 +6305,14 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
/* /*
* First case : a Processing Instruction. * First case : a Processing Instruction.
*/ */
else if ((RAW == '<') && (NXT(1) == '?')) { else if ((*cur == '<') && (cur[1] == '?')) {
xmlParsePI(ctxt); xmlParsePI(ctxt);
} }
/* /*
* Second case : a CDSection * Second case : a CDSection
*/ */
else if ((RAW == '<') && (NXT(1) == '!') && else if ((*cur == '<') && (NXT(1) == '!') &&
(NXT(2) == '[') && (NXT(3) == 'C') && (NXT(2) == '[') && (NXT(3) == 'C') &&
(NXT(4) == 'D') && (NXT(5) == 'A') && (NXT(4) == 'D') && (NXT(5) == 'A') &&
(NXT(6) == 'T') && (NXT(7) == 'A') && (NXT(6) == 'T') && (NXT(7) == 'A') &&
@@ -6304,7 +6323,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
/* /*
* Third case : a comment * Third case : a comment
*/ */
else if ((RAW == '<') && (NXT(1) == '!') && else if ((*cur == '<') && (NXT(1) == '!') &&
(NXT(2) == '-') && (NXT(3) == '-')) { (NXT(2) == '-') && (NXT(3) == '-')) {
xmlParseComment(ctxt); xmlParseComment(ctxt);
ctxt->instate = XML_PARSER_CONTENT; ctxt->instate = XML_PARSER_CONTENT;
@@ -6313,7 +6332,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
/* /*
* Fourth case : a sub-element. * Fourth case : a sub-element.
*/ */
else if (RAW == '<') { else if (*cur == '<') {
xmlParseElement(ctxt); xmlParseElement(ctxt);
} }
@@ -6322,7 +6341,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
* parsing returns it's Name, create the node * parsing returns it's Name, create the node
*/ */
else if (RAW == '&') { else if (*cur == '&') {
xmlParseReference(ctxt); xmlParseReference(ctxt);
} }
@@ -6444,7 +6463,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
return; return;
} }
if (RAW == '>') { if (RAW == '>') {
NEXT; NEXT1;
} else { } else {
ctxt->errNo = XML_ERR_GT_REQUIRED; ctxt->errNo = XML_ERR_GT_REQUIRED;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))