From 857e2ba8cf703e48f7754e5f2315f9d9a31d8235 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Tue, 28 Dec 2010 00:57:20 +0100 Subject: [PATCH] optimization saving some dynamic_cast --- core/AmB2BSession.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index d18c94dd..7de5fbf3 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -595,18 +595,20 @@ int AmB2BCallerSession::relayEvent(AmEvent* ev) { if(other_id.empty()){ - if(dynamic_cast(ev)){ - - B2BSipEvent* sip_ev = dynamic_cast(ev); - B2BConnectEvent* co_ev = dynamic_cast(ev); - - if( (sip_ev && sip_ev->forward) || co_ev ) { - createCalleeSession(); - if (other_id.length()) { - MONITORING_LOG(getLocalTag().c_str(), "b2b_leg", other_id.c_str()); - } + bool create_callee = false; + B2BSipEvent* sip_ev = dynamic_cast(ev); + if (sip_ev && sip_ev->forward) + create_callee = true; + else + create_callee = dynamic_cast(ev) != NULL; + + if (create_callee) { + createCalleeSession(); + if (other_id.length()) { + MONITORING_LOG(getLocalTag().c_str(), "b2b_leg", other_id.c_str()); } } + } return AmB2BSession::relayEvent(ev);