Sunday, April 18, 2010

Kamailio 3.0.x - DYK-02 - expressions

Constant expressions are pre-computed at startup.

See also: Kamailio 3.0.x - DYK - Table of Content
# dialed number 1234*493012345678
$var(minlen) = 4 + 1 + 7;
$var(minlen) = 12;
The above two lines are equivalent in performance at runtime. In 1.5.x or older, the right side constant expressions were computer every time a SIP message was processed.

I have some configs where I do lot of customer-code oriented routing and I use the minimum length in order to detect fast whether is a dialing error. In order to remember over the time why I chose a particular value for a minimum length, I like to write it detailed:
if($rU =~ "^1")
{ # first bunch of client codes - 3 digits
$var(minlen) = 3 /* client code */ + 1 /* separator */ + 7 /* min DID len */;
} else {
# next bunch of client codes - 4 digits
$var(minlen) = 4 /* client code */ + 1 /* separator */ + 7 /* min DID len */;
}

No comments:

Post a Comment