[SR-Users] Header field manipulation

Daniel-Constantin Mierla miconda at gmail.com
Tue Jul 12 21:18:52 CEST 2011


Hello,

On 7/12/11 8:06 PM, Spencer Thomason wrote:
> Hello all,
> Is it preferable to to a check before removing a header field or to simply call remove_hf()?  Are there any performance considerations?
>
> i.e.
> if is_present_hf("X-Account-Code")
> 		remove_hf("X-Account-Code");
>
> vs
> remove_hf("X-Account-Code");
if you just remove it in the IF condition, then the second is better.

is_present_hf() searches the through the header lists and returns true 
at first match or false when all headers were tried without a match. 
remove_hf() searches as well through the list of headers and removes 
when the name matches, going up to the last header.

With latest CPUs processing power, probably will be an unnoticeable 
performance difference, all the operations are in memory. But the check 
for the existence of that header is prety much useless in your case.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list