chasing xmlStrEqual calls and removed them when comparing mode and modeURI
authorDaniel Veillard <veillard@src.gnome.org>
Sat, 22 Jan 2005 21:16:15 +0000 (21:16 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Sat, 22 Jan 2005 21:16:15 +0000 (21:16 +0000)
* libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
  libxslt/xslt.c libxslt/xsltInternals.h: chasing xmlStrEqual
  calls and removed them when comparing mode and modeURI for
  templates by interning those strings when compiling the
  stylesheets.
Daniel

ChangeLog
libxslt/pattern.c
libxslt/preproc.c
libxslt/templates.c
libxslt/xslt.c
libxslt/xsltInternals.h
libxslt/xsltwin32config.h

index fdc4623..9c02700 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sat Jan 22 22:14:26 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
+         libxslt/xslt.c libxslt/xsltInternals.h: chasing xmlStrEqual
+         calls and removed them when comparing mode and modeURI for
+         templates by interning those strings when compiling the
+         stylesheets.
+
 Sat Jan 22 19:17:13 CET 2005 Daniel Veillard <daniel@veillard.com>
 
        * configure.in: small fix for local setup
index e785f3c..deb3d76 100644 (file)
@@ -151,10 +151,6 @@ xsltFreeCompMatch(xsltCompMatchPtr comp) {
        return;
     if (comp->pattern != NULL)
        xmlFree((xmlChar *)comp->pattern);
-    if (comp->mode != NULL)
-       xmlFree((xmlChar *)comp->mode);
-    if (comp->modeURI != NULL)
-       xmlFree((xmlChar *)comp->modeURI);
     if (comp->nsList != NULL)
        xmlFree(comp->nsList);
     for (i = 0;i < comp->nbStep;i++) {
@@ -392,7 +388,10 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
     if (mode != NULL) {
        if (comp->mode == NULL)
            return(0);
-       if ((comp->mode != mode) && (!xmlStrEqual(comp->mode, mode)))
+       /*
+        * both mode strings must be interned on the stylesheet dictionary
+        */
+       if (comp->mode != mode)
            return(0);
     } else {
        if (comp->mode != NULL)
@@ -401,8 +400,10 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
     if (modeURI != NULL) {
        if (comp->modeURI == NULL)
            return(0);
-       if ((comp->modeURI != modeURI) &&
-           (!xmlStrEqual(comp->modeURI, modeURI)))
+       /*
+        * both modeURI strings must be interned on the stylesheet dictionary
+        */
+       if (comp->modeURI != modeURI)
            return(0);
     } else {
        if (comp->modeURI != NULL)
@@ -1908,9 +1909,9 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
        
        pat->template = cur;
        if (mode != NULL)
-           pat->mode = xmlStrdup(mode);
+           pat->mode = xmlDictLookup(style->dict, mode, -1);
        if (modeURI != NULL)
-           pat->modeURI = xmlStrdup(modeURI);
+           pat->modeURI = xmlDictLookup(style->dict, modeURI, -1);
        if (priority != XSLT_PAT_NO_PRIORITY)
            pat->priority = priority;
 
index 963b465..a55874d 100644 (file)
@@ -869,9 +869,9 @@ xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst) {
        if (prop == NULL) {
            if (style != NULL) style->errors++;
        } else {
-           comp->mode = prop;
+           comp->mode = xmlDictLookup(style->dict, prop, -1);
            if (URI != NULL) {
-               comp->modeURI = xmlStrdup(URI);
+               comp->modeURI = xmlDictLookup(style->dict, URI, -1);
            } else {
                comp->modeURI = NULL;
            }
index f574f0f..780b80a 100644 (file)
@@ -506,7 +506,7 @@ xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target,
            } else if ((ctxt->internalized) && (target != NULL) &&
                       (target->doc != NULL) &&
                       (target->doc->dict == ctxt->dict)) {
-               text->content = value;
+               text->content = (xmlChar *) value;
            } else {
                text->content = xmlStrdup(value);
            }
index c01f7a9..30018d2 100644 (file)
@@ -319,8 +319,10 @@ xsltFreeTemplate(xsltTemplatePtr template) {
     if (template->match) xmlFree(template->match);
     if (template->name) xmlFree(template->name);
     if (template->nameURI) xmlFree(template->nameURI);
+/*
     if (template->mode) xmlFree(template->mode);
     if (template->modeURI) xmlFree(template->modeURI);
+ */
     if (template->inheritedNs) xmlFree(template->inheritedNs);
     memset(template, -1, sizeof(xsltTemplate));
     xmlFree(template);
@@ -1780,15 +1782,14 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
            if (URI != NULL)
                modeURI = xmlStrdup(URI);
        }
-       ret->mode = mode;
-       ret->modeURI = modeURI;
+       ret->mode = xmlDictLookup(style->dict, mode, -1);
+       ret->modeURI = xmlDictLookup(style->dict, modeURI, -1);
 #ifdef WITH_XSLT_DEBUG_PARSING
        xsltGenericDebug(xsltGenericDebugContext,
             "xsltParseStylesheetTemplate: mode %s\n", mode);
 #endif
-    } else {
-       mode = NULL;
-       modeURI = NULL;
+        if (mode != NULL) xmlFree(mode);
+       if (modeURI != NULL) xmlFree(modeURI);
     }
     prop = xsltGetNsProp(template, (const xmlChar *)"match", XSLT_NAMESPACE);
     if (prop != NULL) {
@@ -1855,7 +1856,7 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
     xsltParseTemplateContent(style, template);
     ret->elem = template;
     ret->content = template->children;
-    xsltAddTemplate(style, ret, mode, modeURI);
+    xsltAddTemplate(style, ret, ret->mode, ret->modeURI);
 
 error:
     for (;exclPrefixes > 0;exclPrefixes--)
index 6591cb1..0965ded 100644 (file)
@@ -95,8 +95,8 @@ struct _xsltTemplate {
     float priority;    /* as given from the stylesheet, not computed */
     xmlChar *name;     /* the local part of the name QName */
     xmlChar *nameURI;  /* the URI part of the name QName */
-    xmlChar *mode;     /* the local part of the mode QName */
-    xmlChar *modeURI;  /* the URI part of the mode QName */
+    const xmlChar *mode;/* the local part of the mode QName */
+    const xmlChar *modeURI;/* the URI part of the mode QName */
     xmlNodePtr content;        /* the template replacement value */
     xmlNodePtr elem;   /* the source element */
 
index e51340e..1d88726 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
  *
  * extra version information, used to show a CVS compilation
  */
-#define LIBXSLT_VERSION_EXTRA "-CVS990"
+#define LIBXSLT_VERSION_EXTRA "-CVS991"
 
 /**
  * WITH_XSLT_DEBUG: