From 04d6ede62919e469416765416f9721d2d2f67ee9 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Mon, 14 Oct 2019 12:03:41 -0500 Subject: Minor refactor in strings rewriter (#3387) --- src/theory/strings/theory_strings_rewriter.cpp | 47 +++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'src/theory/strings') diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index fa3addf1f..d3ec6d35c 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -732,30 +732,39 @@ Node TheoryStringsRewriter::rewriteConcat(Node node) Assert(node.getKind() == kind::STRING_CONCAT); Trace("strings-rewrite-debug") << "Strings::rewriteConcat start " << node << std::endl; + NodeManager* nm = NodeManager::currentNM(); Node retNode = node; std::vector node_vec; Node preNode = Node::null(); - for(unsigned int i=0; imkConst( preNode.getConst().concat( tmpNode[0].getConst() ) ); - node_vec.push_back( preNode ); - } else { - node_vec.push_back( preNode ); - node_vec.push_back( tmpNode[0] ); - } - preNode = Node::null(); - ++j; + for (Node tmpNode : node) + { + if (tmpNode.getKind() == STRING_CONCAT) + { + unsigned j = 0; + // combine the first term with the previous constant if applicable + if (!preNode.isNull()) + { + if (tmpNode[0].isConst()) + { + preNode = nm->mkConst( + preNode.getConst().concat(tmpNode[0].getConst())); + node_vec.push_back(preNode); } - for(; j