Forwarding reply from author/maintainer of XML::LibXML.

-------- Original Message --------
Subject: Re: Xpath query acceleration
Date: Thu, 17 Jun 2010 14:09:33 +0200
From: Petr Pajas <[email protected]>
To: Tom Metro <[email protected]>
CC: L-boston-pm <[email protected]>

Depends on what you call slow and it does not make much sense using
XPath lookup for this.

If your XPath expressions involve sorting of largish node sets (.//
may trigger sorting), then calling $doc->indexElements() once for the
WSD schema file could help, because otherwise sorting to document
order isn't O(n log(n)) as one would expect since comparison of the
document order of two nodes is not O(1).

Traversing the tree in Perl and using $node->attributes may or may not
be faster (note that the Perl-XS-Perl transitions are surprisingly
expensive even if the function you call in C is a noop, so introducing
more such calls may slow your program down as well).

I'd suggest: if the above don't help (and even if they do), look at
the cases where you use the XPath and for stuff like the one you
mentioned consider scanning once through all xs:attribute using @name
and $type_def as keys.

-- Petr


_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to