From b12da91f642bd0ee187547016f648a7b2f8024cc Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Sun, 23 Jan 2011 03:00:06 +0100 Subject: [PATCH] dsm: execution reordered (small optimization) --- apps/dsm/DSMStateEngine.cpp | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/dsm/DSMStateEngine.cpp b/apps/dsm/DSMStateEngine.cpp index 1a20be66..47295f1d 100644 --- a/apps/dsm/DSMStateEngine.cpp +++ b/apps/dsm/DSMStateEngine.cpp @@ -228,32 +228,10 @@ bool DSMStateEngine::runactions(vector::iterator from, vector::iterator to, AmSession* sess, DSMSession* sc_sess, DSMCondition::EventType event, map* event_params, bool& is_consumed) { - DBG("running %zd actions\n", to - from); + DBG("running %zd DSM action elements\n", to - from); for (vector::iterator it=from; it != to; it++) { - DSMConditionTree* cond_tree = dynamic_cast(*it); - if (cond_tree) { - DBG("checking conditions\n"); - vector::iterator con=cond_tree->conditions.begin(); - while (con!=cond_tree->conditions.end()) { - if (!(*con)->_match(sess, sc_sess, event, event_params)) - break; - con++; - } - if (con == cond_tree->conditions.end()) { - DBG("condition tree matched.\n"); - if (runactions(cond_tree->run_if_true.begin(), cond_tree->run_if_true.end(), - sess, sc_sess, event, event_params, is_consumed)) - return true; - } else { - if(runactions(cond_tree->run_if_false.begin(), cond_tree->run_if_false.end(), - sess, sc_sess, event, event_params, is_consumed)) - return true; - } - } - DSMAction* dsm_act = dynamic_cast(*it); - if (dsm_act) { DBG("executing '%s'\n", (dsm_act)->name.c_str()); if ((dsm_act)->execute(sess, sc_sess, event, event_params)) { @@ -287,6 +265,28 @@ bool DSMStateEngine::runactions(vector::iterator from, } } } + + DSMConditionTree* cond_tree = dynamic_cast(*it); + if (cond_tree) { + DBG("checking conditions\n"); + vector::iterator con=cond_tree->conditions.begin(); + while (con!=cond_tree->conditions.end()) { + if (!(*con)->_match(sess, sc_sess, event, event_params)) + break; + con++; + } + if (con == cond_tree->conditions.end()) { + DBG("condition tree matched.\n"); + if (runactions(cond_tree->run_if_true.begin(), cond_tree->run_if_true.end(), + sess, sc_sess, event, event_params, is_consumed)) + return true; + } else { + if(runactions(cond_tree->run_if_false.begin(), cond_tree->run_if_false.end(), + sess, sc_sess, event, event_params, is_consumed)) + return true; + } + } + } return false; }