| 12943 | #endif /* XPATH_STREAMING */ |
| 12944 | |
| 12945 | static void |
| 12946 | xmlXPathOptimizeExpression(xmlXPathParserContextPtr pctxt, |
| 12947 | xmlXPathStepOpPtr op) |
| 12948 | { |
| 12949 | xmlXPathCompExprPtr comp = pctxt->comp; |
| 12950 | xmlXPathContextPtr ctxt; |
| 12951 | |
| 12952 | /* |
| 12953 | * Try to rewrite "descendant-or-self::node()/foo" to an optimized |
| 12954 | * internal representation. |
| 12955 | */ |
| 12956 | |
| 12957 | if ((op->op == XPATH_OP_COLLECT /* 11 */) && |
| 12958 | (op->ch1 != -1) && |
| 12959 | (op->ch2 == -1 /* no predicate */)) |
| 12960 | { |
| 12961 | xmlXPathStepOpPtr prevop = &comp->steps[op->ch1]; |
| 12962 | |
| 12963 | if ((prevop->op == XPATH_OP_COLLECT /* 11 */) && |
| 12964 | ((xmlXPathAxisVal) prevop->value == |
| 12965 | AXIS_DESCENDANT_OR_SELF) && |
| 12966 | (prevop->ch2 == -1) && |
| 12967 | ((xmlXPathTestVal) prevop->value2 == NODE_TEST_TYPE) && |
| 12968 | ((xmlXPathTypeVal) prevop->value3 == NODE_TYPE_NODE)) |
| 12969 | { |
| 12970 | /* |
| 12971 | * This is a "descendant-or-self::node()" without predicates. |
| 12972 | * Try to eliminate it. |
| 12973 | */ |
| 12974 | |
| 12975 | switch ((xmlXPathAxisVal) op->value) { |
| 12976 | case AXIS_CHILD: |
| 12977 | case AXIS_DESCENDANT: |
| 12978 | /* |
| 12979 | * Convert "descendant-or-self::node()/child::" or |
| 12980 | * "descendant-or-self::node()/descendant::" to |
| 12981 | * "descendant::" |
| 12982 | */ |
| 12983 | op->ch1 = prevop->ch1; |
| 12984 | op->value = AXIS_DESCENDANT; |
| 12985 | break; |
| 12986 | case AXIS_SELF: |
| 12987 | case AXIS_DESCENDANT_OR_SELF: |
| 12988 | /* |
| 12989 | * Convert "descendant-or-self::node()/self::" or |
| 12990 | * "descendant-or-self::node()/descendant-or-self::" to |
| 12991 | * to "descendant-or-self::" |
| 12992 | */ |
| 12993 | op->ch1 = prevop->ch1; |
| 12994 | op->value = AXIS_DESCENDANT_OR_SELF; |
| 12995 | break; |
| 12996 | default: |
| 12997 | break; |
| 12998 | } |
| 12999 | } |
| 13000 | } |
| 13001 | |
| 13002 | /* OP_VALUE has invalid ch1. */ |
no outgoing calls
no test coverage detected