Module: check_mk
Branch: master
Commit: 7156acda5aab4d4c74225cf970297f9658c5b616
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7156acda5aab4d…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Mar 20 10:49:15 2018 +0100
Make smart constructors even smarter.
Change-Id: Ie650c4094e06b2fe68f5f54a20f74195729b8876
---
livestatus/src/AndingFilter.cc | 4 +++-
livestatus/src/OringFilter.cc | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/livestatus/src/AndingFilter.cc b/livestatus/src/AndingFilter.cc
index 98d967d..2b03b5f 100644
--- a/livestatus/src/AndingFilter.cc
+++ b/livestatus/src/AndingFilter.cc
@@ -43,7 +43,9 @@ std::unique_ptr<Filter> AndingFilter::make(Kind kind, Filters
subfilters) {
std::make_move_iterator(conjuncts.begin()),
std::make_move_iterator(conjuncts.end()));
}
- return std::make_unique<AndingFilter>(kind, std::move(filters), Secret());
+ return filters.size() == 1 ? std::move(filters[0])
+ : std::make_unique<AndingFilter>(
+ kind, std::move(filters), Secret());
}
bool AndingFilter::accepts(Row row, const contact *auth_user,
diff --git a/livestatus/src/OringFilter.cc b/livestatus/src/OringFilter.cc
index d184014..04b0132 100644
--- a/livestatus/src/OringFilter.cc
+++ b/livestatus/src/OringFilter.cc
@@ -43,7 +43,9 @@ std::unique_ptr<Filter> OringFilter::make(Kind kind, Filters
subfilters) {
std::make_move_iterator(disjuncts.begin()),
std::make_move_iterator(disjuncts.end()));
}
- return std::make_unique<OringFilter>(kind, std::move(filters), Secret());
+ return filters.size() == 1 ? std::move(filters[0])
+ : std::make_unique<OringFilter>(
+ kind, std::move(filters), Secret());
}
bool OringFilter::accepts(Row row, const contact *auth_user,