tracing/filter: Optimize short ciruit check
The test if we should break out early for OR and AND operations can be optimized by comparing the current result with (pred->op == OP_OR) That is if the result is true and the op is an OP_OR, or if the result is false and the op is not an OP_OR (thus an OP_AND) we can break out early in either case. Otherwise we continue processing. Cc: Tom Zanussi <tzanussi@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt
parent
61e9dea20e
commit
5571927418
@@ -426,9 +426,15 @@ int filter_match_preds(struct event_filter *filter, void *rec)
|
|||||||
pred->parent, &move);
|
pred->parent, &move);
|
||||||
continue;
|
continue;
|
||||||
case MOVE_UP_FROM_LEFT:
|
case MOVE_UP_FROM_LEFT:
|
||||||
/* Check for short circuits */
|
/*
|
||||||
if ((match && pred->op == OP_OR) ||
|
* Check for short circuits.
|
||||||
(!match && pred->op == OP_AND)) {
|
*
|
||||||
|
* Optimization: !!match == (pred->op == OP_OR)
|
||||||
|
* is the same as:
|
||||||
|
* if ((match && pred->op == OP_OR) ||
|
||||||
|
* (!match && pred->op == OP_AND))
|
||||||
|
*/
|
||||||
|
if (!!match == (pred->op == OP_OR)) {
|
||||||
if (pred == root)
|
if (pred == root)
|
||||||
break;
|
break;
|
||||||
pred = get_pred_parent(pred, preds,
|
pred = get_pred_parent(pred, preds,
|
||||||
|
Reference in New Issue
Block a user