From 8e1c3685d4d0b40ee5f36f11334eccc9314109c9 Mon Sep 17 00:00:00 2001 From: ccremers Date: Sun, 13 Jun 2004 21:15:14 +0000 Subject: [PATCH] - Moved some redundant checks for knowledge tuple adding, making it slightly faster. - Fixed some error reporting to go to stderr. --- src/knowledge.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/knowledge.c b/src/knowledge.c index 5449985..69c7533 100644 --- a/src/knowledge.c +++ b/src/knowledge.c @@ -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);