mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Code Cleanup
- Just found out about std::vector::back, after all these years.
This commit is contained in:
parent
d83b2d5e36
commit
7c910e46be
3 changed files with 16 additions and 14 deletions
|
@ -52,8 +52,10 @@ Expression::~Expression ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Expression::eval (Task& task)
|
bool Expression::eval (Task& task)
|
||||||
{
|
{
|
||||||
// TODO Duplicate the _postfix vector as the operating stack.
|
std::vector <std::pair <std::string, std::string> >::iterator arg;
|
||||||
// TODO ...
|
for (arg = _postfix.begin (); arg != _postfix.end (); ++arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -430,9 +432,9 @@ void Expression::to_postfix ()
|
||||||
else if (arg->first == ")")
|
else if (arg->first == ")")
|
||||||
{
|
{
|
||||||
while (op_stack.size () > 0 &&
|
while (op_stack.size () > 0 &&
|
||||||
op_stack[op_stack.size () - 1].first != "(")
|
op_stack.back ().first != "(")
|
||||||
{
|
{
|
||||||
_postfix.push_back (op_stack[op_stack.size () - 1]);
|
_postfix.push_back (op_stack.back ());
|
||||||
op_stack.pop_back ();
|
op_stack.pop_back ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,11 +453,11 @@ void Expression::to_postfix ()
|
||||||
int precedence2;
|
int precedence2;
|
||||||
char associativity2;
|
char associativity2;
|
||||||
while (op_stack.size () > 0 &&
|
while (op_stack.size () > 0 &&
|
||||||
Arguments::is_operator (op_stack[op_stack.size () - 1].first, type2, precedence2, associativity2) &&
|
Arguments::is_operator (op_stack.back ().first, type2, precedence2, associativity2) &&
|
||||||
((associativity == 'l' && precedence <= precedence2) ||
|
((associativity == 'l' && precedence <= precedence2) ||
|
||||||
(associativity == 'r' && precedence < precedence2)))
|
(associativity == 'r' && precedence < precedence2)))
|
||||||
{
|
{
|
||||||
_postfix.push_back (op_stack[op_stack.size () - 1]);
|
_postfix.push_back (op_stack.back ());
|
||||||
op_stack.pop_back ();
|
op_stack.pop_back ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,11 +471,11 @@ void Expression::to_postfix ()
|
||||||
|
|
||||||
while (op_stack.size () != 0)
|
while (op_stack.size () != 0)
|
||||||
{
|
{
|
||||||
if (op_stack[op_stack.size () - 1].first == "(" ||
|
if (op_stack.back ().first == "(" ||
|
||||||
op_stack[op_stack.size () - 1].first == ")")
|
op_stack.back ().first == ")")
|
||||||
throw std::string ("Mismatched parentheses in expression");
|
throw std::string ("Mismatched parentheses in expression");
|
||||||
|
|
||||||
_postfix.push_back (op_stack[op_stack.size () - 1]);
|
_postfix.push_back (op_stack.back ());
|
||||||
op_stack.pop_back ();
|
op_stack.pop_back ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -832,7 +832,7 @@ void Chart::calculateRates (std::vector <time_t>& sequence)
|
||||||
{
|
{
|
||||||
// If there are no current pending tasks, then it is meaningless to find
|
// If there are no current pending tasks, then it is meaningless to find
|
||||||
// rates or estimated completion date.
|
// rates or estimated completion date.
|
||||||
if (bars[sequence[sequence.size () - 1]].pending == 0)
|
if (bars[sequence.back ()].pending == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Calculate how many items we have.
|
// Calculate how many items we have.
|
||||||
|
@ -936,7 +936,7 @@ void Chart::calculateRates (std::vector <time_t>& sequence)
|
||||||
// Estimate completion
|
// Estimate completion
|
||||||
if (fix_rate > find_rate)
|
if (fix_rate > find_rate)
|
||||||
{
|
{
|
||||||
int current_pending = bars[sequence[sequence.size () - 1]].pending;
|
int current_pending = bars[sequence.back ()].pending;
|
||||||
int remaining_days = (int) (current_pending / (fix_rate - find_rate));
|
int remaining_days = (int) (current_pending / (fix_rate - find_rate));
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
|
|
|
@ -235,7 +235,7 @@ std::string CmdImport::task_1_4_3 (const std::vector <std::string>& lines)
|
||||||
if (fields[f][0] != '\'' &&
|
if (fields[f][0] != '\'' &&
|
||||||
fields[f][fields[f].length () - 1] == '\'')
|
fields[f][fields[f].length () - 1] == '\'')
|
||||||
{
|
{
|
||||||
modified[modified.size () - 1] += "," + fields[f];
|
modified.back () += "," + fields[f];
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -391,7 +391,7 @@ std::string CmdImport::task_1_5_0 (const std::vector <std::string>& lines)
|
||||||
if (fields[f][0] != '\'' &&
|
if (fields[f][0] != '\'' &&
|
||||||
fields[f][fields[f].length () - 1] == '\'')
|
fields[f][fields[f].length () - 1] == '\'')
|
||||||
{
|
{
|
||||||
modified[modified.size () - 1] += "," + fields[f];
|
modified.back () += "," + fields[f];
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -552,7 +552,7 @@ std::string CmdImport::task_1_6_0 (const std::vector <std::string>& lines)
|
||||||
if (fields[f][0] != '\'' &&
|
if (fields[f][0] != '\'' &&
|
||||||
fields[f][fields[f].length () - 1] == '\'')
|
fields[f][fields[f].length () - 1] == '\'')
|
||||||
{
|
{
|
||||||
modified[modified.size () - 1] += "," + fields[f];
|
modified.back () += "," + fields[f];
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue