Internal changes
Information about the type hierarchy is now cached in a new data structure
(called TypeHierarchy
) referenced from the NamePool
.
The aim is to improve the performance of type checking both at compile time and at run-time.
For some time (since before Saxon 6.5) Saxon has evaluated an expression such as A < B
as min(A) lt max(B)
. This optimization is now done as a compile-time rewrite, rather than
being decided at run-time. The expansion min(A) lt max(B)
is now used only if neither operand
is known to be a singleton. In an expression such as PRICE > 3.50
, where it is known that the second
operand is a singleton, the expansion used is now some $p in PRICE satisfies $p gt 3.50
; this gives a
better chance of finishing early than the min/max comparison. An important benefit of doing these rewrites at
compile time, apart from simplifying the run-time code, is that the
rewritten expression is a candidate for further optimization, for example it may be possible to move the
computation of min(A)
out of a loop.
A new optimization has been introduced to ensure that a recursive function that builds a sequence by
incremental append operations now has linear performance: the time taken, and the memory used, are both
proportional to the length of the sequence (and to the number of recursive calls). Note that it is useful
to write such functions to be tail recursive. The optimization typically operates when a function returns a result
that is obtained by appending to the sequence supplied as the argument. This optimization makes use of a new
sequence representation (ShareableSequence
) that allows many sequences to share the same underlying
list in memory, provided that the value of each of the sequences is a leading sublist of this underlying list.
In an expression such as A and f:call(P)
, the call on f:call()
is now a candidate
for tail-call optimization. This is achieved by rewriting the expression A and B
as
if (A) then B else false()
.
The XMLChar
module, originally taken from Xerces 2.5.0, has been replaced by the version from Xerces 2.7.1.
This offers improved speed of initialization. The XML11Char
from Xerces 2.7.1 is also now included. All checking
of XML names is now done using a NameChecker
obtained from the Configuration
object;
this uses the XML 1.0 or XML 1.1 rules depending on the XML version setting.