MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathCompOpEvalFilterFirst

Function xmlXPathCompOpEvalFilterFirst

ThirdParty/libxml2/vtklibxml2/xpath.c:11692–11782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11690
11691#ifdef XP_OPTIMIZED_FILTER_FIRST
11692static int
11693xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
11694 xmlXPathStepOpPtr op, xmlNodePtr * first)
11695{
11696 int total = 0;
11697 xmlXPathCompExprPtr comp;
11698 xmlXPathObjectPtr obj;
11699 xmlNodeSetPtr set;
11700
11701 CHECK_ERROR0;
11702 comp = ctxt->comp;
11703 /*
11704 * Optimization for ()[last()] selection i.e. the last elem
11705 */
11706 if ((op->ch1 != -1) && (op->ch2 != -1) &&
11707 (comp->steps[op->ch1].op == XPATH_OP_SORT) &&
11708 (comp->steps[op->ch2].op == XPATH_OP_SORT)) {
11709 int f = comp->steps[op->ch2].ch1;
11710
11711 if ((f != -1) &&
11712 (comp->steps[f].op == XPATH_OP_FUNCTION) &&
11713 (comp->steps[f].value5 == NULL) &&
11714 (comp->steps[f].value == 0) &&
11715 (comp->steps[f].value4 != NULL) &&
11716 (xmlStrEqual
11717 (comp->steps[f].value4, BAD_CAST "last"))) {
11718 xmlNodePtr last = NULL;
11719
11720 total +=
11721 xmlXPathCompOpEvalLast(ctxt,
11722 &comp->steps[op->ch1],
11723 &last);
11724 CHECK_ERROR0;
11725 /*
11726 * The nodeset should be in document order,
11727 * Keep only the last value
11728 */
11729 if ((ctxt->value != NULL) &&
11730 (ctxt->value->type == XPATH_NODESET) &&
11731 (ctxt->value->nodesetval != NULL) &&
11732 (ctxt->value->nodesetval->nodeTab != NULL) &&
11733 (ctxt->value->nodesetval->nodeNr > 1)) {
11734 xmlXPathNodeSetKeepLast(ctxt->value->nodesetval);
11735 *first = *(ctxt->value->nodesetval->nodeTab);
11736 }
11737 return (total);
11738 }
11739 }
11740
11741 if (op->ch1 != -1)
11742 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
11743 CHECK_ERROR0;
11744 if (op->ch2 == -1)
11745 return (total);
11746 if (ctxt->value == NULL)
11747 return (total);
11748
11749#ifdef LIBXML_XPTR_LOCS_ENABLED

Callers 1

xmlXPathCompOpEvalFirstFunction · 0.85

Calls 8

xmlStrEqualFunction · 0.85
xmlXPathCompOpEvalLastFunction · 0.85
xmlXPathNodeSetKeepLastFunction · 0.85
xmlXPathCompOpEvalFunction · 0.85
valuePopFunction · 0.85
xmlXPathNodeSetFilterFunction · 0.85
valuePushFunction · 0.85

Tested by

no test coverage detected