Context: GC now only called when the commands request it

This commit is contained in:
Paul Beckingham 2015-08-02 15:54:24 -04:00
parent 0c85725a4c
commit a604e14ea9
2 changed files with 3 additions and 7 deletions

View file

@ -432,9 +432,9 @@ int Context::dispatch (std::string &out)
Command* c = commands[command]; Command* c = commands[command];
assert (c); assert (c);
// GC is invoked prior to running any command that displays task IDs, if // The command know whether they need a GC.
// possible. if (c->needs_gc () &&
if (c->displays_id () && !tdb2.read_only ()) ! tdb2.read_only ())
{ {
run_gc = config.getBoolean ("gc"); run_gc = config.getBoolean ("gc");
tdb2.gc (); tdb2.gc ();

View file

@ -59,9 +59,6 @@ int CmdProjects::execute (std::string& output)
{ {
int rc = 0; int rc = 0;
// Enforce the garbage collector to show correct task counts
context.tdb2.gc ();
// Get all the tasks. // Get all the tasks.
handleRecurrence (); handleRecurrence ();
auto tasks = context.tdb2.pending.get_tasks (); auto tasks = context.tdb2.pending.get_tasks ();
@ -74,7 +71,6 @@ int CmdProjects::execute (std::string& output)
Filter filter; Filter filter;
std::vector <Task> filtered; std::vector <Task> filtered;
filter.subset (tasks, filtered); filter.subset (tasks, filtered);
int quantity = filtered.size (); int quantity = filtered.size ();
std::stringstream out; std::stringstream out;