aboutsummaryrefslogtreecommitdiffstats
path: root/SAX2.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2005-08-25 13:19:21 +0000
committerDaniel Veillard <veillard@src.gnome.org>2005-08-25 13:19:21 +0000
commit8874b94cd2e2086f4cefe026286e0f64cac6ec9a (patch)
tree640c7e31f9cd75634487bb9074cc74516209aab9 /SAX2.c
parent3854c57a99852edc952cd69d4e7330b39031035c (diff)
downloadandroid_external_libxml2-8874b94cd2e2086f4cefe026286e0f64cac6ec9a.tar.gz
android_external_libxml2-8874b94cd2e2086f4cefe026286e0f64cac6ec9a.tar.bz2
android_external_libxml2-8874b94cd2e2086f4cefe026286e0f64cac6ec9a.zip
added a parser XML_PARSE_COMPACT option to allocate small text nodes (less
* HTMLparser.c parser.c SAX2.c debugXML.c tree.c valid.c xmlreader.c xmllint.c include/libxml/HTMLparser.h include/libxml/parser.h: added a parser XML_PARSE_COMPACT option to allocate small text nodes (less than 8 bytes on 32bits, less than 16bytes on 64bits) directly within the node, various changes to cope with this. * result/XPath/tests/* result/XPath/xptr/* result/xmlid/*: this slightly change the output Daniel
Diffstat (limited to 'SAX2.c')
-rw-r--r--SAX2.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/SAX2.c b/SAX2.c
index 241e90de..a73fa1fa 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1777,6 +1777,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
xmlErrMemory(ctxt, "xmlSAX2Characters");
return(NULL);
}
+ memset(ret, 0, sizeof(xmlNode));
/*
* intern the formatting blanks found between tags, or the
* very short strings
@@ -1784,7 +1785,14 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
if (ctxt->dictNames) {
xmlChar cur = str[len];
- if ((len <= 3) && ((cur == '"') || (cur == '\'') ||
+ if ((len < (int) (2 * sizeof(void *))) &&
+ (ctxt->options & XML_PARSE_COMPACT)) {
+ /* store the string in the node overrithing properties and nsDef */
+ xmlChar *tmp = (xmlChar *) &(ret->properties);
+ memcpy(tmp, str, len);
+ tmp[len] = 0;
+ intern = tmp;
+ } else if ((len <= 3) && ((cur == '"') || (cur == '\'') ||
((cur == '<') && (str[len + 1] != '!')))) {
intern = xmlDictLookup(ctxt->dict, str, len);
} else if (IS_BLANK_CH(*str) && (len < 60) && (cur == '<') &&
@@ -1798,7 +1806,6 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
}
}
skip:
- memset(ret, 0, sizeof(xmlNode));
ret->type = XML_TEXT_NODE;
ret->name = xmlStringText;
@@ -2407,8 +2414,11 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
* We try to minimaze realloc() uses and avoid copying
* and recomputing length over and over.
*/
- if ((ctxt->nodemem == ctxt->nodelen + 1) &&
- (xmlDictOwns(ctxt->dict, lastChild->content))) {
+ if (lastChild->content == (xmlChar *)&(lastChild->properties)) {
+ lastChild->content = xmlStrdup(lastChild->content);
+ lastChild->properties = NULL;
+ } else if ((ctxt->nodemem == ctxt->nodelen + 1) &&
+ (xmlDictOwns(ctxt->dict, lastChild->content))) {
lastChild->content = xmlStrdup(lastChild->content);
}
if (ctxt->nodelen + len >= ctxt->nodemem) {