From d6ad010085ca98bcaa1ecd453542339f5275008c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 23:50:54 -0400 Subject: [PATCH] Parser - ::findOperator moves brnach pruning outside the iterated loop. --- src/Parser.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index af8562a24..4ab8b18c3 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -1493,7 +1493,6 @@ void Parser::findUUIDList () void Parser::findOperator () { context.debug ("Parser::findOperator"); - bool action = false; // Find the category. std::pair ::const_iterator, std::multimap ::const_iterator> c; @@ -1505,6 +1504,7 @@ void Parser::findOperator () for (e = c.first; e != c.second; ++e) options.push_back (e->second); + std::vector prune; std::vector nodes; collect (nodes); std::vector ::iterator i; @@ -1513,13 +1513,16 @@ void Parser::findOperator () if (std::find (options.begin (), options.end (), (*i)->attribute ("raw")) != options.end ()) { (*i)->unTag ("?"); - (*i)->removeAllBranches (); (*i)->tag ("OP"); - action = true; + prune.push_back (*i); } } - if (action) + // Prune branches outside the loop. + for (i = prune.begin (); i != prune.end (); ++i) + (*i)->removeAllBranches (); + + if (prune.size ()) context.debug (_tree->dump ()); }