GNOME Bugzilla – Bug 345561
Optimization of processing of variables and parameters
Last modified: 2021-07-05 11:00:23 UTC
We should make the way variables/parameters are acquired more efficient. We should eliminate the number of intermediate copies of the values of variables/parameters. Currently variables and parameters in XPath expressions are looked up dynamically during evaluation; the process generates some intermediate copies of the variable's value. Example: <xsl:template match="/"> <xsl:variable name="var-1" select="'var-value'"/> <xsl:value-of select="$var-1"/> </xsl:template> The variable is acquired via: xmlXPathVariableLookup() (xpath.c) --> xsltXPathVariableLookup() (libxslt/variables.c) --> xsltVariableLookup() --> xsltStackLookup() Later, in xsltVariableLookup(), the XPath object, which is the value of the variable, is copied with xmlXPathObjectCopy(). Later, in e.g. xsltValueOf(), this object is then converted to a string object with xmlXPathConvertString(), which creates another intermediate object (and sorts if a node set); then the string is aquired via xsltCopyTextString() from the XPath object. Proposals: 1) Find a way of binding the variables statically to the AST of the XPath expression. 2) a) Eliminate the copy of the variables value (XPath object). This could be done by having flag on the XPath object which marks it as immutable. b) Eliminate the intermediate creation of an XPath string object, by using xmlXPathCastToString() rather than xmlXPathConvertString().
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxslt/-/issues/ Thank you for your understanding and your help.