mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Optimization - TDB2 access
- Broke TDB2::load into TDB2::load, TDB2::loadPending and TDB2::loadCompleted. - Converted "projects" and "tags" reports to use this.
This commit is contained in:
parent
9776495286
commit
8728312da6
3 changed files with 45 additions and 4 deletions
43
src/TDB2.cpp
43
src/TDB2.cpp
|
@ -154,11 +154,22 @@ void TDB2::unlock ()
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Returns number of filtered tasks.
|
// Returns number of filtered tasks.
|
||||||
|
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
||||||
|
// multiple files.
|
||||||
int TDB2::load (std::vector <Task>& tasks, Filter& filter)
|
int TDB2::load (std::vector <Task>& tasks, Filter& filter)
|
||||||
{
|
{
|
||||||
// Note: tasks.clear () is deliberately not called, to allow the combination
|
loadPending (tasks, filter);
|
||||||
// of multiple files.
|
loadCompleted (tasks, filter);
|
||||||
|
|
||||||
|
return tasks.size ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Returns number of filtered tasks.
|
||||||
|
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
||||||
|
// multiple files.
|
||||||
|
int TDB2::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
|
{
|
||||||
std::string file;
|
std::string file;
|
||||||
int line_number;
|
int line_number;
|
||||||
|
|
||||||
|
@ -185,6 +196,34 @@ int TDB2::load (std::vector <Task>& tasks, Filter& filter)
|
||||||
|
|
||||||
++line_number;
|
++line_number;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (std::string& e)
|
||||||
|
{
|
||||||
|
std::stringstream s;
|
||||||
|
s << " int " << file << " at line " << line_number;
|
||||||
|
throw e + s.str ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tasks.size ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Returns number of filtered tasks.
|
||||||
|
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
||||||
|
// multiple files.
|
||||||
|
int TDB2::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
||||||
|
{
|
||||||
|
std::string file;
|
||||||
|
int line_number;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
char line[T_LINE_MAX];
|
||||||
|
foreach (location, mLocations)
|
||||||
|
{
|
||||||
|
std::cout << "# location.path: " << location->path << std::endl;
|
||||||
|
|
||||||
// TODO If the filter contains Status:x where x is not deleted or
|
// TODO If the filter contains Status:x where x is not deleted or
|
||||||
// completed, then this can be skipped.
|
// completed, then this can be skipped.
|
||||||
|
|
|
@ -51,6 +51,8 @@ public:
|
||||||
void unlock ();
|
void unlock ();
|
||||||
|
|
||||||
int load (std::vector <Task>&, Filter&);
|
int load (std::vector <Task>&, Filter&);
|
||||||
|
int loadPending (std::vector <Task>&, Filter&);
|
||||||
|
int loadCompleted (std::vector <Task>&, Filter&);
|
||||||
void add (Task&);
|
void add (Task&);
|
||||||
void update (Task&, Task&);
|
void update (Task&, Task&);
|
||||||
int commit ();
|
int commit ();
|
||||||
|
|
|
@ -98,7 +98,7 @@ std::string handleProjects ()
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.get ("locking", true));
|
context.tdb.lock (context.config.get ("locking", true));
|
||||||
int quantity = context.tdb.load (tasks, context.filter);
|
int quantity = context.tdb.loadPending (tasks, context.filter);
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
// Scan all the tasks for their project name, building a map using project
|
// Scan all the tasks for their project name, building a map using project
|
||||||
|
@ -155,7 +155,7 @@ std::string handleTags ()
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.get ("locking", true));
|
context.tdb.lock (context.config.get ("locking", true));
|
||||||
int quantity = context.tdb.load (tasks, context.filter);
|
int quantity = context.tdb.loadPending (tasks, context.filter);
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
// Scan all the tasks for their project name, building a map using project
|
// Scan all the tasks for their project name, building a map using project
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue