- 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:
parent
bd76b63a37
commit
8e1c3685d4
@ -141,8 +141,8 @@ knowledgeAddTerm (Knowledge know, Term term)
|
||||
{
|
||||
if (know == NULL)
|
||||
{
|
||||
printf
|
||||
("Warning: trying to add term to uninitialised (NULL) Know pointer.\n");
|
||||
fprintf
|
||||
(stderr, "Warning: trying to add term to uninitialised (NULL) Know pointer.\n");
|
||||
return 1;
|
||||
}
|
||||
if (term == NULL)
|
||||
@ -150,16 +150,19 @@ knowledgeAddTerm (Knowledge know, Term 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 */
|
||||
if (inKnowledge (know, term))
|
||||
return 0;
|
||||
|
||||
if (isTermTuple (term))
|
||||
{
|
||||
knowledgeAddTerm (know, term->left.op1);
|
||||
knowledgeAddTerm (know, term->right.op2);
|
||||
}
|
||||
|
||||
/* adding variables? */
|
||||
know->vars = termlistAddVariables (know->vars, term);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user