Performance improvements:

- Added parse-free convenience functions
This commit is contained in:
Paul Beckingham 2012-05-05 13:24:11 -04:00
parent 53d829cfc1
commit 873376c287
6 changed files with 61 additions and 25 deletions

View file

@ -9,10 +9,10 @@ Features
+ Added the new 'indented' format for the 'project' attribute. + Added the new 'indented' format for the 'project' attribute.
+ The 'projects' report now uses 'project.indented' format. + The 'projects' report now uses 'project.indented' format.
+ The 'summary' report now uses 'project.indented' format. + The 'summary' report now uses 'project.indented' format.
+ Introduced a new filter optimization that recognizes filters with no 'OR', or + Performance improvements:
'XOR' operators, includes IDs, but does not include UUIDs. This combination + Added parse-free convenience functions
means completed.data is not referenced. + Filter optimization: with no 'OR' or 'XOR' operators, no UUIDS but with IDs
+ Sped up task sorting by skipping re-interpretation of certain data types. the completed.data file is not referenced
Bugs Bugs
+ Fixed bug #954, which caused bulk deletions when using a UUID filter term and + Fixed bug #954, which caused bulk deletions when using a UUID filter term and

View file

@ -602,43 +602,43 @@ int Date::second () const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator== (const Date& rhs) bool Date::operator== (const Date& rhs) const
{ {
return rhs._t == _t; return rhs._t == _t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator!= (const Date& rhs) bool Date::operator!= (const Date& rhs) const
{ {
return rhs._t != _t; return rhs._t != _t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator< (const Date& rhs) bool Date::operator< (const Date& rhs) const
{ {
return _t < rhs._t; return _t < rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator> (const Date& rhs) bool Date::operator> (const Date& rhs) const
{ {
return _t > rhs._t; return _t > rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator<= (const Date& rhs) bool Date::operator<= (const Date& rhs) const
{ {
return _t <= rhs._t; return _t <= rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator>= (const Date& rhs) bool Date::operator>= (const Date& rhs) const
{ {
return _t >= rhs._t; return _t >= rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::sameHour (const Date& rhs) bool Date::sameHour (const Date& rhs) const
{ {
if (this->year () == rhs.year () && if (this->year () == rhs.year () &&
this->month () == rhs.month () && this->month () == rhs.month () &&
@ -650,7 +650,7 @@ bool Date::sameHour (const Date& rhs)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::sameDay (const Date& rhs) bool Date::sameDay (const Date& rhs) const
{ {
if (this->year () == rhs.year () && if (this->year () == rhs.year () &&
this->month () == rhs.month () && this->month () == rhs.month () &&
@ -661,7 +661,7 @@ bool Date::sameDay (const Date& rhs)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::sameMonth (const Date& rhs) bool Date::sameMonth (const Date& rhs) const
{ {
if (this->year () == rhs.year () && if (this->year () == rhs.year () &&
this->month () == rhs.month ()) this->month () == rhs.month ())
@ -671,7 +671,7 @@ bool Date::sameMonth (const Date& rhs)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::sameYear (const Date& rhs) bool Date::sameYear (const Date& rhs) const
{ {
if (this->year () == rhs.year ()) if (this->year () == rhs.year ())
return true; return true;

View file

@ -85,16 +85,16 @@ public:
int minute () const; int minute () const;
int second () const; int second () const;
bool operator== (const Date&); bool operator== (const Date&) const;
bool operator!= (const Date&); bool operator!= (const Date&) const;
bool operator< (const Date&); bool operator< (const Date&) const;
bool operator> (const Date&); bool operator> (const Date&) const;
bool operator<= (const Date&); bool operator<= (const Date&) const;
bool operator>= (const Date&); bool operator>= (const Date&) const;
bool sameHour (const Date&); bool sameHour (const Date&) const;
bool sameDay (const Date&); bool sameDay (const Date&) const;
bool sameMonth (const Date&); bool sameMonth (const Date&) const;
bool sameYear (const Date&); bool sameYear (const Date&) const;
Date operator+ (const int); Date operator+ (const int);
Date operator- (const int); Date operator- (const int);

View file

@ -47,6 +47,7 @@ Date getNextRecurrence (Date&, std::string&);
bool generateDueDates (Task&, std::vector <Date>&); bool generateDueDates (Task&, std::vector <Date>&);
void updateRecurrenceMask (Task&); void updateRecurrenceMask (Task&);
int getDueState (const std::string&); int getDueState (const std::string&);
int getDueState (const Date&);
bool nag (Task&); bool nag (Task&);
// rules.cpp // rules.cpp

View file

@ -386,7 +386,7 @@ int getDueState (const std::string& due)
Date dt (::atoi (due.c_str ())); Date dt (::atoi (due.c_str ()));
// rightNow is the current date + time. // rightNow is the current date + time.
Date rightNow; static Date rightNow;
Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ()); Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ());
if (dt < rightNow) if (dt < rightNow)
@ -408,6 +408,36 @@ int getDueState (const std::string& due)
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////////////////
// Determines whether a task is overdue. Returns
// 0 = not due at all
// 1 = imminent
// 2 = today
// 3 = overdue
int getDueState (const Date& due)
{
// rightNow is the current date + time.
static Date rightNow;
Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ());
if (due < rightNow)
return 3;
if (rightNow.sameDay (due))
return 2;
int imminentperiod = context.config.getInteger ("due");
if (imminentperiod == 0)
return 1;
Date imminentDay = thisDay + imminentperiod * 86400;
if (due < imminentDay)
return 1;
return 0;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Returns a Boolean indicator as to whether a nag message was generated, so // Returns a Boolean indicator as to whether a nag message was generated, so
// that commands can control the number of nag messages displayed (ie one is // that commands can control the number of nag messages displayed (ie one is

View file

@ -45,6 +45,11 @@ qx{../src/task rc:count.rc log two};
qx{../src/task rc:count.rc add three}; qx{../src/task rc:count.rc add three};
qx{../src/task rc:count.rc 2 delete}; qx{../src/task rc:count.rc 2 delete};
qx{../src/task rc:count.rc add four wait:eom}; qx{../src/task rc:count.rc add four wait:eom};
# TODO This fails when today == eom. For example, on 2012-04-30 at 8:00:00, the
# value for 'eom' is 2012-04-30 0:00:00, which is already past due, which
# means a second child task is generated. This would be fixed by 'eom'
# expanding to 2012-04-30 24:00:00, as per ISO-8601.
qx{../src/task rc:count.rc add five due:eom recur:monthly}; qx{../src/task rc:count.rc add five due:eom recur:monthly};
my $output = qx{../src/task rc:count.rc count}; my $output = qx{../src/task rc:count.rc count};