mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Code Cleanup
- Removed the last uses of 'foreach'. What remains is only code that is being obsoleted, and therefore there is no need to clean that up. - The definition of 'foreach' in util.h must remain until last.
This commit is contained in:
parent
76b30d8d10
commit
56bc5cf755
3 changed files with 36 additions and 22 deletions
|
@ -442,6 +442,7 @@ void TDB::lock (bool lockFile /* = true */)
|
|||
mCompleted.clear ();
|
||||
mModified.clear ();
|
||||
|
||||
|
||||
foreach (location, mLocations)
|
||||
{
|
||||
location->pending = openAndLock (location->path + "/pending.data");
|
||||
|
|
|
@ -134,7 +134,8 @@ static bool followUpstream (
|
|||
{
|
||||
std::vector <Task> blocking;
|
||||
dependencyGetBlocking (task, blocking);
|
||||
foreach (b, blocking)
|
||||
std::vector <Task>::iterator b;
|
||||
for (b = blocking.begin (); b != blocking.end (); ++b)
|
||||
{
|
||||
std::string link = task.get ("uuid") + " -> " + b->get ("uuid");
|
||||
|
||||
|
@ -200,7 +201,8 @@ void dependencyChainOnComplete (Task& task)
|
|||
if (context.config.getBoolean ("dependency.reminder"))
|
||||
{
|
||||
std::cout << "Task " << task.id << " is blocked by:\n";
|
||||
foreach (b, blocking)
|
||||
std::vector <Task>::iterator b;
|
||||
for (b = blocking.begin (); b != blocking.end (); ++b)
|
||||
std::cout << " " << b->id << " " << b->get ("description") << "\n";
|
||||
}
|
||||
|
||||
|
@ -210,7 +212,8 @@ void dependencyChainOnComplete (Task& task)
|
|||
if (context.config.getBoolean ("dependency.reminder"))
|
||||
{
|
||||
std::cout << "and is blocking:\n";
|
||||
foreach (b, blocked)
|
||||
std::vector <Task>::iterator b;
|
||||
for (b = blocked.begin (); b != blocked.end (); ++b)
|
||||
std::cout << " " << b->id << " " << b->get ("description") << "\n";
|
||||
}
|
||||
|
||||
|
@ -219,19 +222,21 @@ void dependencyChainOnComplete (Task& task)
|
|||
{
|
||||
// Repair the chain - everything in blocked should now depend on
|
||||
// everything in blocking, instead of task.id.
|
||||
foreach (left, blocked)
|
||||
std::vector <Task>::iterator left;
|
||||
std::vector <Task>::iterator right;
|
||||
for (left = blocked.begin (); left != blocked.end (); ++left)
|
||||
{
|
||||
left->removeDependency (task.id);
|
||||
|
||||
foreach (right, blocking)
|
||||
for (right = blocking.begin (); right != blocking.end (); ++right)
|
||||
left->addDependency (right->id);
|
||||
}
|
||||
|
||||
// Now update TDB, now that the updates have all occurred.
|
||||
foreach (left, blocked)
|
||||
for (left = blocked.begin (); left != blocked.end (); ++left)
|
||||
context.tdb.update (*left);
|
||||
|
||||
foreach (right, blocking)
|
||||
for (right = blocking.begin (); right != blocking.end (); ++right)
|
||||
context.tdb.update (*right);
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +256,8 @@ void dependencyChainOnStart (Task& task)
|
|||
if (blocking.size ())
|
||||
{
|
||||
std::cout << "Task " << task.id << " is blocked by:\n";
|
||||
foreach (b, blocking)
|
||||
std::vector <Task>::iterator b;
|
||||
for (b = blocking.begin (); b != blocking.end (); ++b)
|
||||
std::cout << " " << b->id << " " << b->get ("description") << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +299,8 @@ void dependencyChainOnModify (Task& before, Task& after)
|
|||
std::vector <Task> blocked;
|
||||
dependencyGetBlocked (after, blocked);
|
||||
|
||||
foreach (b, blocked)
|
||||
std::vector <Task>::iterator b;
|
||||
for (b = blocked.begin (); b != blocked.end (); ++b)
|
||||
{
|
||||
std::cout << "# dependencyChainOnModify\n";
|
||||
}
|
||||
|
|
|
@ -45,11 +45,12 @@ bool taskDiff (const Task& before, const Task& after)
|
|||
// Attributes are all there is, so figure the different attribute names
|
||||
// between before and after.
|
||||
std::vector <std::string> beforeAtts;
|
||||
foreach (att, before)
|
||||
std::map <std::string, Att>::const_iterator att;
|
||||
for (att = before.begin (); att != before.end (); ++att)
|
||||
beforeAtts.push_back (att->first);
|
||||
|
||||
std::vector <std::string> afterAtts;
|
||||
foreach (att, after)
|
||||
for (att = after.begin (); att != after.end (); ++att)
|
||||
afterAtts.push_back (att->first);
|
||||
|
||||
std::vector <std::string> beforeOnly;
|
||||
|
@ -60,7 +61,8 @@ bool taskDiff (const Task& before, const Task& after)
|
|||
afterOnly.size ())
|
||||
return true;
|
||||
|
||||
foreach (name, beforeAtts)
|
||||
std::vector <std::string>::iterator name;
|
||||
for (name = beforeAtts.begin (); name != beforeAtts.end (); ++name)
|
||||
if (*name != "uuid" &&
|
||||
before.get (*name) != after.get (*name))
|
||||
return true;
|
||||
|
@ -74,11 +76,12 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
// Attributes are all there is, so figure the different attribute names
|
||||
// between before and after.
|
||||
std::vector <std::string> beforeAtts;
|
||||
foreach (att, before)
|
||||
std::map <std::string, Att>::const_iterator att;
|
||||
for (att = before.begin (); att != before.end (); ++att)
|
||||
beforeAtts.push_back (att->first);
|
||||
|
||||
std::vector <std::string> afterAtts;
|
||||
foreach (att, after)
|
||||
for (att = after.begin (); att != after.end (); ++att)
|
||||
afterAtts.push_back (att->first);
|
||||
|
||||
std::vector <std::string> beforeOnly;
|
||||
|
@ -87,12 +90,13 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
|
||||
// Now start generating a description of the differences.
|
||||
std::stringstream out;
|
||||
foreach (name, beforeOnly)
|
||||
std::vector <std::string>::iterator name;
|
||||
for (name = beforeOnly.begin (); name != beforeOnly.end (); ++name)
|
||||
out << " - "
|
||||
<< ucFirst(*name)
|
||||
<< " will be deleted.\n";
|
||||
|
||||
foreach (name, afterOnly)
|
||||
for (name = afterOnly.begin (); name != afterOnly.end (); ++name)
|
||||
{
|
||||
if (*name == "depends")
|
||||
{
|
||||
|
@ -115,7 +119,7 @@ std::string taskDifferences (const Task& before, const Task& after)
|
|||
<< "'.\n";
|
||||
}
|
||||
|
||||
foreach (name, beforeAtts)
|
||||
for (name = beforeAtts.begin (); name != beforeAtts.end (); ++name)
|
||||
if (*name != "uuid" &&
|
||||
before.get (*name) != after.get (*name))
|
||||
{
|
||||
|
@ -162,11 +166,12 @@ std::string taskInfoDifferences (const Task& before, const Task& after)
|
|||
// Attributes are all there is, so figure the different attribute names
|
||||
// between before and after.
|
||||
std::vector <std::string> beforeAtts;
|
||||
foreach (att, before)
|
||||
std::map <std::string, Att>::const_iterator att;
|
||||
for (att = before.begin (); att != before.end (); ++att)
|
||||
beforeAtts.push_back (att->first);
|
||||
|
||||
std::vector <std::string> afterAtts;
|
||||
foreach (att, after)
|
||||
for (att = after.begin (); att != after.end (); ++att)
|
||||
afterAtts.push_back (att->first);
|
||||
|
||||
std::vector <std::string> beforeOnly;
|
||||
|
@ -175,7 +180,8 @@ std::string taskInfoDifferences (const Task& before, const Task& after)
|
|||
|
||||
// Now start generating a description of the differences.
|
||||
std::stringstream out;
|
||||
foreach (name, beforeOnly)
|
||||
std::vector <std::string>::iterator name;
|
||||
for (name = beforeOnly.begin (); name != beforeOnly.end (); ++name)
|
||||
{
|
||||
if (*name == "depends")
|
||||
{
|
||||
|
@ -201,7 +207,7 @@ std::string taskInfoDifferences (const Task& before, const Task& after)
|
|||
}
|
||||
}
|
||||
|
||||
foreach (name, afterOnly)
|
||||
for (name = afterOnly.begin (); name != afterOnly.end (); ++name)
|
||||
{
|
||||
if (*name == "depends")
|
||||
{
|
||||
|
@ -228,7 +234,7 @@ std::string taskInfoDifferences (const Task& before, const Task& after)
|
|||
<< "'.\n";
|
||||
}
|
||||
|
||||
foreach (name, beforeAtts)
|
||||
for (name = beforeAtts.begin (); name != beforeAtts.end (); ++name)
|
||||
if (*name != "uuid" &&
|
||||
before.get (*name) != after.get (*name) &&
|
||||
before.get (*name) != "" && after.get (*name) != "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue