[OpenSER-Users] About efficiency in conditionals

Klaus Darilion klaus.mailinglists at pernau.at
Tue Oct 16 15:18:58 CEST 2007


Iñaki Baz Castillo wrote:
> Hi, I'm wondering which solution (A or B) is more efficient in case method is 
> NOT an INVITE:
> 
> 
> A)  if ( (method=="INVITE") && (isflagset(5) || isbflagset(6)) )
> 
> B)  if ( mehtod=="INVITE" )
>
AFAIK the conditions are checked in the order they appear and stop as 
soon as possible. In your case in != INVITE it should be the same.

Further, if you use is_method("INVITE") it is even faster.

regards
klaus


> 
> My question is: Is faster B because does less comparasions?
> or does OpenSer break A conditional during first condition (method=="INVITE") 
> because it's false so then A and B are equally efficient?
> 
> 
> And which is more efficient (C or D) when all the conditions are true?
> 
> C)  if ( (method=="INVITE") && (isflagset(5) || isbflagset(6)) ) {
>               ....
> 
> D)  if ( method=="INVITE" ) {
>              if ( (isflagset(5) || isbflagset(6)) ) {
>                       ...
> 
> 
> Thanks for any explanation.
> Best regards.
> 
> 





More information about the sr-users mailing list