- ::findModifications code cleanup.
- ::findStrayModifications now prunes nodes out of the iterator loop.
This commit is contained in:
Paul Beckingham 2014-08-23 17:34:16 -04:00
parent 13e49f6b00
commit e353d8eb8b

View file

@ -1616,7 +1616,6 @@ void Parser::findModifications ()
{ {
(*i)->unTag ("?"); (*i)->unTag ("?");
(*i)->tag ("MODIFICATION"); (*i)->tag ("MODIFICATION");
// (*i)->removeAllBranches ();
prune.push_back (*i); prune.push_back (*i);
} }
} }
@ -1633,12 +1632,12 @@ void Parser::findModifications ()
void Parser::findStrayModifications () void Parser::findStrayModifications ()
{ {
context.debug ("Parser::findStrayModifications"); context.debug ("Parser::findStrayModifications");
bool action = false;
std::string command = getCommand (); std::string command = getCommand ();
if (command == "add" || if (command == "add" ||
command == "log") command == "log")
{ {
std::vector <Tree*> prune;
std::vector <Tree*> nodes; std::vector <Tree*> nodes;
collect (nodes, collectAll); collect (nodes, collectAll);
std::vector <Tree*>::iterator i; std::vector <Tree*>::iterator i;
@ -1648,14 +1647,17 @@ void Parser::findStrayModifications ()
{ {
(*i)->unTag ("FILTER"); (*i)->unTag ("FILTER");
(*i)->tag ("MODIFICATION"); (*i)->tag ("MODIFICATION");
(*i)->removeAllBranches (); prune.push_back (*i);
action = true;
} }
} }
}
if (action) // Prune branches outside the loop.
context.debug (_tree->dump ()); for (i = prune.begin (); i != prune.end (); ++i)
(*i)->removeAllBranches ();
if (prune.size ())
context.debug (_tree->dump ());
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////