- Moved some redundant checks for knowledge tuple adding, making it slightly

faster.
- Fixed some error reporting to go to stderr.
This commit is contained in:
ccremers 2004-06-13 21:15:14 +00:00
parent bd76b63a37
commit 8e1c3685d4

View File

@ -141,8 +141,8 @@ knowledgeAddTerm (Knowledge know, Term term)
{ {
if (know == NULL) if (know == NULL)
{ {
printf fprintf
("Warning: trying to add term to uninitialised (NULL) Know pointer.\n"); (stderr, "Warning: trying to add term to uninitialised (NULL) Know pointer.\n");
return 1; return 1;
} }
if (term == NULL) if (term == NULL)
@ -150,16 +150,19 @@ knowledgeAddTerm (Knowledge know, Term term)
term = deVar (term); term = deVar (term);
/* for tuples, simply recurse for components */
if (isTermTuple (term))
{
int status;
status = knowledgeAddTerm (know, term->left.op1);
return knowledgeAddTerm (know, term->right.op2) || status;
}
/* test whether we knew it before */ /* test whether we knew it before */
if (inKnowledge (know, term)) if (inKnowledge (know, term))
return 0; return 0;
if (isTermTuple (term))
{
knowledgeAddTerm (know, term->left.op1);
knowledgeAddTerm (know, term->right.op2);
}
/* adding variables? */ /* adding variables? */
know->vars = termlistAddVariables (know->vars, term); know->vars = termlistAddVariables (know->vars, term);