From 30f873e8633340cc2f1d7aee4bb82526c673d639 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 13 Feb 2017 18:33:49 +0100 Subject: Avoid triggering reinsert if the leader doesn't change. --- common/datastorequery.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'common') diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 3ba8f40..34d2bae 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp @@ -288,16 +288,23 @@ public: //TODO if old and new are the same a modification would be enough auto oldSelectionResult = mSelectedValues.take(reductionValueBa); - //remove old result - readEntity(oldSelectionResult, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { - callback({entity, Sink::Operation_Removal}); - }); - - //add new result - mSelectedValues.insert(reductionValueBa, selectionResult); - readEntity(selectionResult, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { - callback({entity, Sink::Operation_Creation, aggregateValues}); - }); + if (oldSelectionResult == selectionResult) { + mSelectedValues.insert(reductionValueBa, selectionResult); + readEntity(selectionResult, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + callback({entity, Sink::Operation_Modification, aggregateValues}); + }); + } else { + //remove old result + readEntity(oldSelectionResult, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + callback({entity, Sink::Operation_Removal}); + }); + + //add new result + mSelectedValues.insert(reductionValueBa, selectionResult); + readEntity(selectionResult, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + callback({entity, Sink::Operation_Creation, aggregateValues}); + }); + } } } return false; -- cgit v1.2.3