From 3169efbcaa882c427d9cc1bbb6dbd187efe98f45 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 17 Aug 2018 18:49:27 +0300 Subject: [PATCH] Remove duplicates when merging choice conditions --- source/choicecondition.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/choicecondition.h b/source/choicecondition.h index 91b5e71..c2f7f0e 100644 --- a/source/choicecondition.h +++ b/source/choicecondition.h @@ -1,6 +1,7 @@ #ifndef CHOICECONDITION_H_ #define CHOICECONDITION_H_ +#include #include "condition.h" #include "filter.h" @@ -71,14 +72,13 @@ ChoiceCondition *ChoiceCondition::merge(const std::vector &co { if(dynamic_cast(&parent) && !conditions.empty()) { - ChoiceCondition *result = 0; + ChoiceCondition *result = new ChoiceCondition(std::vector()); for(std::vector::const_iterator i=conditions.begin(); i!=conditions.end(); ++i) { const std::vector &v = static_cast *>(*i)->values; - if(!result) - result = new ChoiceCondition(v); - else - result->values.insert(result->values.end(), v.begin(), v.end()); + for(typename std::vector::const_iterator j=v.begin(); j!=v.end(); ++j) + if(Msp::find(result->values, *j)==result->values.end()) + result->values.push_back(*j); } return result; } -- 2.45.2