jsquery_extract.c
static ExtractedNode *
makeEntries(ExtractedNode *node, MakeEntryHandler handler, Pointer extra)
{
	if (node->type == eAnd || node->type == eOr)
	{
		int i, j = 0;
		ExtractedNode *child;
		for (i = 0; i < node->args.count; i++)
		{
			child = node->args.items[i];
			if (!child)
				continue;
			/* Skip non-selective AND children */
			if (child->sClass > node->sClass &&
				node->type == eAnd &&
				!child->forceIndex)
				continue;
			child = makeEntries(child, handler, extra);
			if (child)
			{
				node->args.items[j] = child;
				j++;
			}
			else if (node->type == eOr)
			{
				return NULL;
			}
		}
		if (j == 1)
		{
			return node->args.items[0];
		}
		if (j > 0)
		{
			node->args.count = j;
			return node;
		}
		else
		{
			return NULL;
		}
	}
	else
	{
		int entryNum;

		if (node->hint == jsqNoIndex)
			return NULL;

		entryNum = handler(node, extra);
		if (entryNum >= 0)
		{
			node->entryNum = entryNum;
			return node;
		}
		else
		{
			return NULL;
		}
	}
}
/*
 * Make entries for all leaf tree nodes using user-provided handler.
 */
Make entries for all leaf tree nodes using user-provided handler.
Make entries for all leaf tree nodes using user - provided handler .
static ExtractedNode *
makeEntries(ExtractedNode *node, MakeEntryHandler handler, Pointer extra)
{
	if (node->type == eAnd || node->type == eOr)
	{
		int i, j = 0;
		ExtractedNode *child;
		for (i = 0; i < node->args.count; i++)
		{
			child = node->args.items[i];
			if (!child)
				continue;
			if (child->sClass > node->sClass &&
				node->type == eAnd &&
				!child->forceIndex)
				continue;
			child = makeEntries(child, handler, extra);
			if (child)
			{
				node->args.items[j] = child;
				j++;
			}
			else if (node->type == eOr)
			{
				return NULL;
			}
		}
		if (j == 1)
		{
			return node->args.items[0];
		}
		if (j > 0)
		{
			node->args.count = j;
			return node;
		}
		else
		{
			return NULL;
		}
	}
	else
	{
		int entryNum;
		if (node->hint == jsqNoIndex)
			return NULL;
		entryNum = handler(node, extra);
		if (entryNum >= 0)
		{
			node->entryNum = entryNum;
			return node;
		}
		else
		{
			return NULL;
		}
	}
}
static ExtractedNode * makeEntries ( ExtractedNode * node , MakeEntryHandler handler , Pointer extra ) { if ( node -> type == eAnd || node -> type == eOr ) { int i , j = 0 ; ExtractedNode * child ; for ( i = 0 ; i < node -> args . count ; i ++ ) { child = node -> args . items [ i ] ; if ( ! child ) continue ; if ( child -> sClass > node -> sClass && node -> type == eAnd && ! child -> forceIndex ) continue ; child = makeEntries ( child , handler , extra ) ; if ( child ) { node -> args . items [ j ] = child ; j ++ ; } else if ( node -> type == eOr ) { return NULL ; } } if ( j == 1 ) { return node -> args . items [ 0 ] ; } if ( j > 0 ) { node -> args . count = j ; return node ; } else { return NULL ; } } else { int entryNum ; if ( node -> hint == jsqNoIndex ) return NULL ; entryNum = handler ( node , extra ) ; if ( entryNum >= 0 ) { node -> entryNum = entryNum ; return node ; } else { return NULL ; } } }
Make entries for all leaf tree nodes using user-provided handler.
Make entries for all leaf tree nodes using user - provided handler .
/* Skip non-selective AND children */