Package com.saxonica.ee.optim
Class CommonSubexpressionPromoter
java.lang.Object
com.saxonica.ee.optim.CommonSubexpressionPromoter
This class is responsible for identifying and extracting common subexpressions within
an expression. For example the expression (x/y/z = 3 or x/y/z = 4) is turned into
(let $zz = x/y/z return ($zz = 3 or $zz = 4).
For simplicity, in this initial version:
(a) we extract at most one subexpression: the one that has the highest
value of instances*cost.
(b) we restrict the scope of the search for duplicates to that part of the expression tree
that shares the same dynamic context (local variables, focus, etc).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSearch for duplicate subexpressions within an expression tree, and if one is found, generate a local variable bound to the common subexpression, replacing the original subexpression with a reference to the new local variable
-
Constructor Details
-
CommonSubexpressionPromoter
-
-
Method Details
-
promoteCommonSubexpressions
Search for duplicate subexpressions within an expression tree, and if one is found, generate a local variable bound to the common subexpression, replacing the original subexpression with a reference to the new local variable- Parameters:
in
- the expression to be searched- Returns:
- the new expression, with common subexpressions promoted; or the original expression unchanged.
-