From e26f0f0dc9ea9ffa9ef2ec2f95c1d7c64a453dfe Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 23:49:06 -0400 Subject: [PATCH] Parser - ::findSubstitution moves branch prining out of 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 5b7c513be..af8562a24 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -874,8 +874,8 @@ void Parser::findPattern () void Parser::findSubstitution () { context.debug ("Parser::findSubstitution"); - bool action = false; + std::vector prune; std::vector nodes; collect (nodes); std::vector ::iterator i; @@ -898,17 +898,20 @@ void Parser::findSubstitution () !Directory (raw).exists ()) { (*i)->unTag ("?"); - (*i)->removeAllBranches (); (*i)->tag ("SUBSTITUTION"); (*i)->attribute ("from", from); (*i)->attribute ("to", to); (*i)->attribute ("global", global ? 1 : 0); - 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 ()); }