Module: sems Branch: sayer/dsm_lang Commit: b12da91f642bd0ee187547016f648a7b2f8024cc URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=b12da91f642bd0ee187547016f648a7b2f8024cc
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Sun Jan 23 03:00:06 2011 +0100 dsm: execution reordered (small optimization) --- apps/dsm/DSMStateEngine.cpp | 46 +++++++++++++++++++++--------------------- 1 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/dsm/DSMStateEngine.cpp b/apps/dsm/DSMStateEngine.cpp index 1a20be6..47295f1 100644 --- a/apps/dsm/DSMStateEngine.cpp +++ b/apps/dsm/DSMStateEngine.cpp @@ -228,32 +228,10 @@ bool DSMStateEngine::runactions(vector<DSMElement*>::iterator from, vector<DSMElement*>::iterator to, AmSession* sess, DSMSession* sc_sess, DSMCondition::EventType event, map<string,string>* event_params, bool& is_consumed) { - DBG("running %zd actions\n", to - from); + DBG("running %zd DSM action elements\n", to - from); for (vector<DSMElement*>::iterator it=from; it != to; it++) { - DSMConditionTree* cond_tree = dynamic_cast<DSMConditionTree*>(*it); - if (cond_tree) { - DBG("checking conditions\n"); - vector<DSMCondition*>::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<DSMAction*>(*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<DSMElement*>::iterator from, } } } + + DSMConditionTree* cond_tree = dynamic_cast<DSMConditionTree*>(*it); + if (cond_tree) { + DBG("checking conditions\n"); + vector<DSMCondition*>::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; } _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
