+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
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 *)
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);
}
#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"
*
* 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) {
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);
}
}
}
}
-#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);
}
}
cur = cur->next;
}
}
-#endif
+
return(NULL);
}