From: Andrew Reynolds Date: Mon, 14 Oct 2019 17:03:41 +0000 (-0500) Subject: Minor refactor in strings rewriter (#3387) X-Git-Tag: cvc5-1.0.0~3890 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=04d6ede62919e469416765416f9721d2d2f67ee9;p=cvc5.git Minor refactor in strings rewriter (#3387) --- 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