Project

Profile

Help

Revision 6f206361

Added by Michael Kay almost 8 years ago

Further fix for bug 2013; plus streaming test cases

View differences:

latest9.5/hej/net/sf/saxon/expr/instruct/CopyOf.java
16 16
import net.sf.saxon.event.*;
17 17
import net.sf.saxon.expr.*;
18 18
import net.sf.saxon.expr.parser.*;
19
import net.sf.saxon.expr.sort.DocumentSorter;
19 20
import net.sf.saxon.lib.NamespaceConstant;
20 21
import net.sf.saxon.lib.ParseOptions;
21 22
import net.sf.saxon.lib.Validation;
......
250 251
        return c;
251 252
    }
252 253

  
253

  
254 254
    /*@NotNull*/
255 255
    public Expression simplify(ExpressionVisitor visitor) throws XPathException {
256 256
        select = visitor.simplify(select);
......
386 386
    /*@NotNull*/
387 387
    public Expression optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException {
388 388
        if (readOnce) {
389
            Expression optcopy = visitor.getConfiguration().obtainOptimizer().optimizeCopy(select);
389
            Expression optcopy;
390
            if (!(select instanceof DocumentSorter)) {
391
                optcopy = visitor.getConfiguration().obtainOptimizer().optimizeCopy(select);
392
                if (optcopy != null) {
393
                    return optcopy;
394
                }
395
            }
396
            select = visitor.optimize(select, contextItemType);
397
            optcopy = visitor.getConfiguration().obtainOptimizer().optimizeCopy(select);
390 398
            if (optcopy != null) {
391 399
                return optcopy;
392 400
            }
401
        } else {
402
            select = visitor.optimize(select, contextItemType);
393 403
        }
394
        select = visitor.optimize(select, contextItemType);
395 404
        if (Literal.isEmptySequence(select)) {
396 405
            return select;
397 406
        }

Also available in: Unified diff