small fix for local setup speeding up some variable lookup. In the process
authorDaniel Veillard <veillard@src.gnome.org>
Sat, 22 Jan 2005 18:19:08 +0000 (18:19 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Sat, 22 Jan 2005 18:19:08 +0000 (18:19 +0000)
* configure.in: small fix for local setup
* libxslt/transform.c libxslt/variables.c : speeding up some
  variable lookup. In the process dug out something nasty about
  ctxt->dict creation and key initialization order.
Daniel

ChangeLog
configure.in
libxslt/transform.c
libxslt/variables.c
libxslt/xsltwin32config.h

index 3b4f609..fdc4623 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Jan 22 19:17:13 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+       * configure.in: small fix for local setup
+       * libxslt/transform.c libxslt/variables.c : speeding up some
+         variable lookup. In the process dug out something nasty about
+         ctxt->dict creation and key initialization order.
+
 Sat Jan 22 16:28:27 CET 2005 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/templates.c libxslt/transform.c libxslt/xslt.c
index c4fba7c..68cf103 100644 (file)
@@ -483,7 +483,7 @@ dnl
 dnl In build tree I use a static version with memory debug enabled
 dnl
 if test "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XSLT" ; then
-    if test "`uname -i`" != "x86_64" ;
+    if test "`uname -i`" != "x86_64" -a -e $HOME/XML/.libs/libxml2.a ;
     then
        LIBXML_LIBS="$HOME/XML/.libs/libxml2.a -lpthread -lz"
     fi
index e032764..ee46980 100644 (file)
@@ -348,6 +348,17 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
     memset(cur, 0, sizeof(xsltTransformContext));
 
     /*
+     * setup of the dictionnary must be done early as some of the
+     * processing later like key handling may need it.
+     */
+    cur->dict = xmlDictCreateSub(style->dict);
+    cur->internalized = ((style->internalized) && (cur->dict != NULL));
+#ifdef WITH_XSLT_DEBUG
+    xsltGenericDebug(xsltGenericDebugContext,
+            "Creating sub-dictionary from stylesheet for transformation\n");
+#endif
+
+    /*
      * initialize the template stack
      */
     cur->templTab = (xsltTemplatePtr *)
@@ -464,13 +475,6 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
     cur->debugStatus = xslDebugStatus;
     cur->traceCode = (unsigned long*) &xsltDefaultTrace;
 
-    cur->dict = xmlDictCreateSub(style->dict);
-    cur->internalized = ((style->internalized) && (cur->dict != NULL));
-#ifdef WITH_XSLT_DEBUG
-    xsltGenericDebug(xsltGenericDebugContext,
-            "Creating sub-dictionary from stylesheet for transformation\n");
-#endif
-
     return(cur);
 }
 
index e2d7fd4..1ee516e 100644 (file)
@@ -22,6 +22,7 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 #include <libxml/parserInternals.h>
+#include <libxml/dict.h>
 #include "xslt.h"
 #include "xsltInternals.h"
 #include "xsltutils.h"
@@ -250,6 +251,8 @@ xsltFreeStackElemList(xsltStackElemPtr elem) {
  *
  * Locate an element in the stack based on its name.
  */
+static int stack_addr = 0;
+static int stack_cmp = 0;
 static xsltStackElemPtr
 xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
                const xmlChar *nameURI) {
@@ -271,11 +274,13 @@ xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
            if (cur->name == name) {
                if (nameURI == NULL) {
                    if (cur->nameURI == NULL) {
+                       stack_addr++;
                        return(cur);
                    }
                } else {
                    if ((cur->nameURI != NULL) &&
                        (cur->nameURI == nameURI)) {
+                       stack_addr++;
                        return(cur);
                    }
                }
@@ -285,47 +290,28 @@ xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
        }
     }
 
-#if 0
-    if ((xmlDictOwns(ctxt->dict, name) <= 0) ||
-        ((nameURI != NULL) && (xmlDictOwns(ctxt->dict, nameURI) <= 0))) {
-       /*
-        * Redo the lookup with string compares
-        */
-       for (i = ctxt->varsNr; i > ctxt->varsBase; i--) {
-           cur = ctxt->varsTab[i-1];
-           while (cur != NULL) {
-               if (xmlStrEqual(cur->name, name)) {
-                   if (nameURI == NULL) {
-                       if (cur->nameURI == NULL) {
-                           return(cur);
-                       }
-                   } else {
-                       if ((cur->nameURI != NULL) &&
-                           (xmlStrEqual(cur->nameURI, nameURI))) {
-                           return(cur);
-                       }
-                   }
-
-               }
-               cur = cur->next;
-           }
-       }
-    }
-#else
     /*
-     * Redo the lookup with string compares
+     * Redo the lookup with interned string compares
+     * to avoid string compares.
      */
+    name = xmlDictLookup(ctxt->dict, name, -1);
+    if (nameURI != NULL)
+        nameURI = xmlDictLookup(ctxt->dict, nameURI, -1);
+    else
+        nameURI = NULL;
     for (i = ctxt->varsNr; i > ctxt->varsBase; i--) {
        cur = ctxt->varsTab[i-1];
        while (cur != NULL) {
-           if (xmlStrEqual(cur->name, name)) {
+           if (cur->name == name) {
                if (nameURI == NULL) {
                    if (cur->nameURI == NULL) {
+                       stack_cmp++;
                        return(cur);
                    }
                } else {
                    if ((cur->nameURI != NULL) &&
-                       (xmlStrEqual(cur->nameURI, nameURI))) {
+                       (cur->nameURI == nameURI)) {
+                       stack_cmp++;
                        return(cur);
                    }
                }
@@ -334,7 +320,7 @@ xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
            cur = cur->next;
        }
     }
-#endif
+
     return(NULL);
 }
 
index ef04d81..e51340e 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
  *
  * extra version information, used to show a CVS compilation
  */
-#define LIBXSLT_VERSION_EXTRA "-CVS985"
+#define LIBXSLT_VERSION_EXTRA "-CVS990"
 
 /**
  * WITH_XSLT_DEBUG: