Project

Profile

Help

Revision e2316e08

Added by Michael Kay about 12 years ago

Fix bug 2892201 Bad optimization for X[position() = N to last()]

View differences:

latest9.1/bj/net/sf/saxon/expr/FilterExpression.java
583 583
            Expression min = ((IntegerRangeTest)filter).getMinValueExpression();
584 584
            Expression max = ((IntegerRangeTest)filter).getMaxValueExpression();
585 585

  
586
            if (((min.getDependencies() & StaticProperty.DEPENDS_ON_FOCUS) != 0)) {
587
                return null;
588
            }
589
            if (((max.getDependencies() & StaticProperty.DEPENDS_ON_FOCUS) != 0)) {
590
                if (max instanceof Last) {
591
                    return SystemFunction.makeSystemFunction("subsequence", new Expression[]{start, min});
592
                } else {
593
                    return null;
594
                }
595
            }
596

  
586 597
            LetExpression let = new LetExpression();
587 598
            let.setRequiredType(SequenceType.SINGLE_INTEGER);
588 599
            let.setVariableQName(new StructuredQName("nn", NamespaceConstant.SAXON, "nn" + let.hashCode()));
latest9.2/hej/net/sf/saxon/expr/FilterExpression.java
592 592
            Expression min = ((IntegerRangeTest)filter).getMinValueExpression();
593 593
            Expression max = ((IntegerRangeTest)filter).getMaxValueExpression();
594 594

  
595
            if (ExpressionTool.dependsOnFocus(min)) {
596
                return null;
597
            }
598
            if (ExpressionTool.dependsOnFocus(max)) {
599
                if (max instanceof Last) {
600
                    return SystemFunction.makeSystemFunction("subsequence", new Expression[]{start, min});
601
                } else {
602
                    return null;
603
                }
604
            }
605

  
595 606
            LetExpression let = new LetExpression();
596 607
            let.setRequiredType(SequenceType.SINGLE_INTEGER);
597 608
            let.setVariableQName(new StructuredQName("nn", NamespaceConstant.SAXON, "nn" + let.hashCode()));

Also available in: Unified diff