From a604e14ea9d89c24a18b96db18dd51494379fcc9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 2 Aug 2015 15:54:24 -0400 Subject: [PATCH] Context: GC now only called when the commands request it --- src/Context.cpp | 6 +++--- src/commands/CmdProjects.cpp | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 813c6a9ad..40bc31388 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -432,9 +432,9 @@ int Context::dispatch (std::string &out) Command* c = commands[command]; assert (c); - // GC is invoked prior to running any command that displays task IDs, if - // possible. - if (c->displays_id () && !tdb2.read_only ()) + // The command know whether they need a GC. + if (c->needs_gc () && + ! tdb2.read_only ()) { run_gc = config.getBoolean ("gc"); tdb2.gc (); diff --git a/src/commands/CmdProjects.cpp b/src/commands/CmdProjects.cpp index fe5380aec..f08400d11 100644 --- a/src/commands/CmdProjects.cpp +++ b/src/commands/CmdProjects.cpp @@ -59,9 +59,6 @@ int CmdProjects::execute (std::string& output) { int rc = 0; - // Enforce the garbage collector to show correct task counts - context.tdb2.gc (); - // Get all the tasks. handleRecurrence (); auto tasks = context.tdb2.pending.get_tasks (); @@ -74,7 +71,6 @@ int CmdProjects::execute (std::string& output) Filter filter; std::vector filtered; filter.subset (tasks, filtered); - int quantity = filtered.size (); std::stringstream out;