curl-library
Re: strequal() doesnt like NULL
Date: Thu, 23 Aug 2007 16:26:11 +0200
2007/8/23, Guenter Knauf <eflash_at_gmx.net>:.
> Would it make sense to introduce a NULL check in strequal() ?
My personal opinion is that checking if any of the strings equals NULL
should be done outside of the function, as it is most often not a necessary
check. Two reasons:
* If the function is not inlined, it would waste processing time to adjust
the stack, jump in memory and adjust the stack back.
* When performing millions of string comparison each second, processing time
would be wasted in comparing against NULL.
A program that treats strings will most often know on beforehand if the
string is NULL or not, and if it doesn't it can always do the compare
itself.
The difference in speed is not significant, but the habit of disregarding
such tiny differences in speed could eventually result in significant speed
drawbacks when applied to other areas as well.
Received on 2007-08-23