jsquery_extract.c
static void
simplifyRecursive(ExtractedNode *node)
{
	if (node->type == eAnd)
	{
		int				i, groupStart = -1;
		ExtractedNode	*child, *prevChild = NULL;

		for (i = 0; i < node->args.count; i++)
			node->args.items[i]->number = i;

		pg_qsort(node->args.items, node->args.count,
				 sizeof(ExtractedNode *), compareNodes);

		for (i = 0; i < node->args.count; i++)
		{
			child = node->args.items[i];
			if (child->indirect || isLogicalNodeType(child->type))
				break;
			if (!prevChild || comparePathItems(child->path, prevChild->path) != 0)
			{
				if (groupStart >= 0)
					processGroup(node, groupStart, i);
				groupStart = i;
			}
			prevChild = child;
		}
		if (groupStart >= 0)
			processGroup(node, groupStart, i);
	}

	if (node->type == eAnd || node->type == eOr)
	{
		int i;
		for (i = 0; i < node->args.count; i++)
		{
			if (node->args.items[i])
				simplifyRecursive(node->args.items[i]);
		}
	}
}
/*
 * Reduce number of nodes in tree, by turning multiple conditions about
 * same field in same context into one node.
 */
Reduce number of nodes in tree, by turning multiple conditions about
same field in same context into one node.
Reduce number of nodes in tree by turning multiple conditions about same field in same context into one node .
static void
simplifyRecursive(ExtractedNode *node)
{
	if (node->type == eAnd)
	{
		int				i, groupStart = -1;
		ExtractedNode	*child, *prevChild = NULL;
		for (i = 0; i < node->args.count; i++)
			node->args.items[i]->number = i;
		pg_qsort(node->args.items, node->args.count,
				 sizeof(ExtractedNode *), compareNodes);
		for (i = 0; i < node->args.count; i++)
		{
			child = node->args.items[i];
			if (child->indirect || isLogicalNodeType(child->type))
				break;
			if (!prevChild || comparePathItems(child->path, prevChild->path) != 0)
			{
				if (groupStart >= 0)
					processGroup(node, groupStart, i);
				groupStart = i;
			}
			prevChild = child;
		}
		if (groupStart >= 0)
			processGroup(node, groupStart, i);
	}
	if (node->type == eAnd || node->type == eOr)
	{
		int i;
		for (i = 0; i < node->args.count; i++)
		{
			if (node->args.items[i])
				simplifyRecursive(node->args.items[i]);
		}
	}
}
static void simplifyRecursive ( ExtractedNode * node ) { if ( node -> type == eAnd ) { int i , groupStart = -1 ; ExtractedNode * child , * prevChild = NULL ; for ( i = 0 ; i < node -> args . count ; i ++ ) node -> args . items [ i ] -> number = i ; pg_qsort ( node -> args . items , node -> args . count , sizeof ( ExtractedNode * ) , compareNodes ) ; for ( i = 0 ; i < node -> args . count ; i ++ ) { child = node -> args . items [ i ] ; if ( child -> indirect || isLogicalNodeType ( child -> type ) ) break ; if ( ! prevChild || comparePathItems ( child -> path , prevChild -> path ) != 0 ) { if ( groupStart >= 0 ) processGroup ( node , groupStart , i ) ; groupStart = i ; } prevChild = child ; } if ( groupStart >= 0 ) processGroup ( node , groupStart , i ) ; } if ( node -> type == eAnd || node -> type == eOr ) { int i ; for ( i = 0 ; i < node -> args . count ; i ++ ) { if ( node -> args . items [ i ] ) simplifyRecursive ( node -> args . items [ i ] ) ; } } }
Reduce number of nodes in tree, by turning multiple conditions about
 same field in same context into one node.
Reduce number of nodes in tree by turning multiple conditions about same field in same context into one node .