From 6dad8ddb1b6061558e0c95c15854a1f84b9233a5 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 23:42:58 -0400 Subject: [PATCH] Parser - ::findTerminator now moves branch pruning out of the iterated loop. --- src/Parser.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index b693e56eb..bf7b4e540 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -369,7 +369,7 @@ void Parser::findTerminator () { context.debug ("Parser::findTerminator"); bool found = false; - bool action = false; + std::vector prune; std::vector nodes; collect (nodes, collectTerminated); @@ -381,24 +381,26 @@ void Parser::findTerminator () (*i)->attribute ("raw") == "--") { (*i)->unTag ("?"); - (*i)->removeAllBranches (); (*i)->tag ("TERMINATOR"); + prune.push_back (*i); found = true; - action = true; } // Mark subsequent nodes. else if (found) { (*i)->unTag ("?"); - (*i)->removeAllBranches (); (*i)->tag ("WORD"); (*i)->tag ("TERMINATED"); - 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 ()); }