[Asterisk-Dev] FW: asterisk/doc CODING-GUIDELINES,1.4,1.5
joachim
zoachien at securax.org
Wed Jan 19 07:23:58 MST 2005
If its a 0x00 it will stop yes, but if its not, it will continue, while
its not necessary as we already know the string is not zero length.
Which would mean that if the stringlength = 0, there will be no waste of
cpu cycles, if its 1 char or more, it will waste cpu cycles.
If the string is 255 chars, it will use up around 255 times more cpu
cycles if you use the strlen.
Zoa.
Andrew Kohlsmith wrote:
>On January 19, 2005 07:45 am, Jerris, Michael MI wrote:
>
>
>>It would probably be more efficient to check just the first char of the
>>string to see if it is 0 than to loop through the whole string to see if
>>it is > 0 length.
>>
>>
>
>But would strlen()'s loop not terminate on the first 0x00 char?? I mean a
>couple dozen cycles here is not something a user's gonna notice, even in a
>tight loop that is processing strings for Asterisk.
>
>Personally I feel this whole ast_strlen_zero macro (it better be a macro or at
>least inline function!) is poor optimization -- does Asterisk really spend so
>much time in strlen() that it was necessary?
>
>-A.
>_______________________________________________
>Asterisk-Dev mailing list
>Asterisk-Dev at lists.digium.com
>http://lists.digium.com/mailman/listinfo/asterisk-dev
>To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20050119/ec549175/signature.pgp
More information about the asterisk-dev
mailing list