Diffusion Baloo b0dcc732ca98

Simplify Term operator&& and ||

Authored by bruns on Apr 7 2018, 12:45 AM.

Description

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

Details

Committed
brunsApr 7 2018, 11:19 AM
Reviewer
Baloo
Differential Revision
D11826: Simplify Term operator&& and ||
Parents
R293:8fe0a7366d60: GIT_SILENT Upgrade ECM and KF5 version requirements for 5.45.0 release.
Branches
Unknown
Tags
Unknown