From: trevor_hansen Date: Tue, 10 Jan 2012 05:53:22 +0000 (+0000) Subject: Improvement. Replace implementation with a node iterator. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=0958bf55516c437e7fdd0ab2bc7937b8eebc3a5b;p=francis%2Fstp.git Improvement. Replace implementation with a node iterator. git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@1493 e59a4935-1847-0410-ae03-e826735625c1 --- diff --git a/src/AST/ASTmisc.cpp b/src/AST/ASTmisc.cpp index 5040345..d01273b 100644 --- a/src/AST/ASTmisc.cpp +++ b/src/AST/ASTmisc.cpp @@ -9,6 +9,7 @@ #include "AST.h" #include "../STPManager/STPManager.h" +#include "../STPManager/NodeIterator.h" namespace BEEV { @@ -164,31 +165,18 @@ namespace BEEV } -bool containsArrayOps(const ASTNode& n, hash_set & visited) -{ - if (n.GetIndexWidth() > 0) - return true; - - if (n.Degree() ==0) - return false; - - if (visited.find(n.GetNodeNum()) != visited.end()) - return false; - - visited.insert(n.GetNodeNum()); - - for (int i =0; i < n.Degree();i++) - if (containsArrayOps(n[i],visited)) - return true; - - return false; -} - + // True if any descendants are arrays. bool containsArrayOps(const ASTNode&n) { - hash_set visited; - return containsArrayOps(n, visited); + + NodeIterator ni(n, n.GetSTPMgr()->ASTUndefined, *n.GetSTPMgr()); + ASTNode current; + while ((current = ni.next()) != ni.end()) + if (current.GetIndexWidth()>0) + return true; + + return false; } bool isCommutative(const Kind k) {