diff --git a/libxslt/imports.c b/libxslt/imports.c index 9277b4f..8ae3bdb 100644 --- a/libxslt/imports.c +++ b/libxslt/imports.c @@ -400,16 +400,23 @@ xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name, return(NULL); style = ctxt->style; while (style != NULL) { - cur = style->templates; - while (cur != NULL) { - if (xmlStrEqual(name, cur->name)) { - if (((nameURI == NULL) && (cur->nameURI == NULL)) || - ((nameURI != NULL) && (cur->nameURI != NULL) && - (xmlStrEqual(nameURI, cur->nameURI)))) { - return(cur); + if (style->namedTemplatesHash != NULL) { + cur = (xsltTemplatePtr) xmlHashLookup2(style->namedTemplatesHash, + name, nameURI); + if (cur != NULL) + return(cur); + } else { + cur = style->templates; + while (cur != NULL) { + if (xmlStrEqual(name, cur->name)) { + if (((nameURI == NULL) && (cur->nameURI == NULL)) || + ((nameURI != NULL) && (cur->nameURI != NULL) && + (xmlStrEqual(nameURI, cur->nameURI)))) { + return(cur); + } } + cur = cur->next; } - cur = cur->next; } style = xsltNextImport(style);