From 4042cbf964f4c6d1d7c565ad77dac3883e5c5655 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 5 Sep 2015 23:14:15 +0200 Subject: [PATCH] feedback: Replace taskDiff method by Task inequality operator --- src/commands/CmdDenotate.cpp | 2 +- src/commands/CmdImport.cpp | 4 ++-- src/commands/CmdModify.cpp | 2 +- src/feedback.cpp | 29 ----------------------------- src/main.h | 1 - 5 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index be991cd37..f797cb1db 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -124,7 +124,7 @@ int CmdDenotate::execute (std::string& output) } } - if (taskDiff (before, task)) + if (before != task) { std::string question = format (STRING_CMD_DENO_CONFIRM, task.id, diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index 669815db5..6ec292aa5 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -184,10 +184,10 @@ void CmdImport::importSingleTask (json::object* obj) { // "modified:" is automatically set to the current time when a task is // changed. If the imported task has a modification timestamp we need - // to ignore it in taskDiff() in order to check for meaningful + // to ignore it in task comparison in order to check for meaningful // differences. Setting it to the previous value achieves just that. task.set ("modified", before.get ("modified")); - if (taskDiff (before, task)) + if (before != task) { CmdModify modHelper; modHelper.checkConsistency (before, task); diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 9f7d56d47..9fa58e55e 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -76,7 +76,7 @@ int CmdModify::execute (std::string& output) Task before (task); task.modify (Task::modReplace); - if (taskDiff (before, task)) + if (before != task) { // Abort if change introduces inconsistencies. checkConsistency(before, task); diff --git a/src/feedback.cpp b/src/feedback.cpp index cc55fb474..40b3fc594 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -43,35 +43,6 @@ extern Context context; static void countTasks (const std::vector &, const std::string&, int&, int&); -//////////////////////////////////////////////////////////////////////////////// -bool taskDiff (const Task& before, const Task& after) -{ - // Attributes are all there is, so figure the different attribute names - // between before and after. - std::vector beforeAtts; - for (auto& att : before) - beforeAtts.push_back (att.first); - - std::vector afterAtts; - for (auto& att : after) - afterAtts.push_back (att.first); - - std::vector beforeOnly; - std::vector afterOnly; - listDiff (beforeAtts, afterAtts, beforeOnly, afterOnly); - - if (beforeOnly.size () != - afterOnly.size ()) - return true; - - for (auto& name : beforeAtts) - if (name != "uuid" && - before.get (name) != after.get (name)) - return true; - - return false; -} - //////////////////////////////////////////////////////////////////////////////// std::string taskDifferences (const Task& before, const Task& after) { diff --git a/src/main.h b/src/main.h index d1f663904..16d1f854d 100644 --- a/src/main.h +++ b/src/main.h @@ -60,7 +60,6 @@ void dependencyChainOnComplete (Task&); void dependencyChainOnStart (Task&); // feedback.cpp -bool taskDiff (const Task&, const Task&); std::string taskDifferences (const Task&, const Task&); std::string taskInfoDifferences (const Task&, const Task&, const std::string&, long&, const long); std::string renderAttribute (const std::string&, const std::string&, const std::string& format = "");