Simplify Term operator&& and ||
Summary:
The Term(Term, Operator, Term) constructor is identical to the three
separate calls, but saves two separate function calls.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Try to merge terms with identical operations
(a AND b) AND (c OR d) can be merged as (a AND b AND (c OR D), i.e. 2
instead of 3 intermediate AND/OR terms.
This is especially useful if terms are combined with a && b && c && d,
which can be combined into one AND term with 4 subterms, instead of
3 AND terms with 2 subterms each (((a AND b) AND c) AND d).
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Test Plan:
ctest -V -R advancedqueryparser
38: QDEBUG : AdvancedQueryParserTest::testOptimizedLogic(a && b && c && d) result term ( AND ( : a (QString)) ( : b (QString)) ( : c (QString)) ( : d (QString)) ) 38: QDEBUG : AdvancedQueryParserTest::testOptimizedLogic(a && b && c && d) expected term ( AND ( : a (QString)) ( : b (QString)) ( : c (QString)) ( : d (QString)) ) 38: PASS : AdvancedQueryParserTest::testOptimizedLogic(a && b && c && d) 38: QDEBUG : AdvancedQueryParserTest::testOptimizedLogic((a && b) && (c || d)) result term ( AND ( : a (QString)) ( : b (QString)) ( OR ( : c (QString)) ( : d (QString)) ) ) 38: QDEBUG : AdvancedQueryParserTest::testOptimizedLogic((a && b) && (c || d)) expected term ( AND ( : a (QString)) ( : b (QString)) ( OR ( : c (QString)) ( : d (QString)) ) ) 38: PASS : AdvancedQueryParserTest::testOptimizedLogic((a && b) && (c || d))
Reviewers: Baloo, michaelh
Reviewed By: Baloo, michaelh
Subscribers: michaelh, Frameworks
Tags: Frameworks, Baloo
Differential Revision: https://phabricator.kde.org/D11826