From 139011e1aec1452b933ff78810d03affdbaeb8b8 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 24 Apr 2012 00:53:04 -0400 Subject: [PATCH] Performance - Introduced a new filter optimization that recognizes filters with no 'OR', or 'XOR' operators, includes IDs, but does not include UUIDs. This combination means completed.data is not referenced. --- ChangeLog | 3 +++ src/commands/Command.cpp | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7aeb3d21f..dcfc3aaa3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,9 @@ Features + Added the new 'indented' format for the 'project' attribute. + The 'projects' 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 + 'XOR' operators, includes IDs, but does not include UUIDs. This combination + means completed.data is not referenced. Bugs + Fixed bug #964, where the 'projects' command showed the wrong priority labels diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 98bb7b049..cf50a7648 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -338,8 +338,6 @@ void Command::filter (std::vector & output) if (e.evalFilter (*task)) output.push_back (*task); } - else - context.debug ("Command::filter skipping completed.data"); } else { @@ -372,7 +370,37 @@ bool Command::filter_shortcut (const A3& filter) filter[0]._raw == "status" && filter[1]._raw.find ("pending") != std::string::npos && filter[2]._raw == "=") + { + context.debug ("Command::filter skipping completed.data (status:pending only)"); return true; + } + + // Shortcut: If the filter contains no 'or' or 'xor' operators, IDs and no UUIDs. + int countId = 0; + int countUUID = 0; + int countOr = 0; + int countXor = 0; + std::vector ::const_iterator i; + for (i = filter.begin (); i != filter.end (); ++i) + { + if (i->_category == Arg::cat_op) + { + if (i->_raw == "or") ++countOr; + if (i->_raw == "xor") ++countXor; + + } + else if (i->_category == Arg::cat_id) ++countId; + else if (i->_category == Arg::cat_uuid) ++countUUID; + } + + if (countOr == 0 && + countXor == 0 && + countUUID == 0 && + countId > 0) + { + context.debug ("Command::filter skipping completed.data (IDs, no OR, no XOR, no UUID)"); + return true; + } return false; }