Re: [cc65] strcmp to empty string

From: SHAWN JEFFERSON <sjefferson1shaw.ca>
Date: 2010-01-08 18:33:58
Hi,

I had about 20-30 calls to strcmp in my program checking either that a string was empty or that it was not empty.  For one call, I wouldn't have bothered, but for so many, and some within loops, I think it was worth the time to replace them.

----- Original Message -----
From: Per Olofsson <magervalp@gmail.com>
Date: Friday, January 8, 2010 1:32 am

> On Fri, Jan 8, 2010 at 8:37 AM, Shawn Jefferson 
> <sjefferson@shaw.ca> wrote:
> > It never occurred to me to not use strcmp(str, ) == 0 to 
> check for an
> > empty string!  I just converted all these to checks of the 
> first character
> > of the ( string str[0] == \0 and str[0] != \0 ) and saved 
> 341 bytes in
> > my program, plus probably made it a bit faster to execute as well.
> 
> That sounds strange. This is what I get with 2.13.1:

<snip>

> strcmp is larger (20 bytes vs 15) and quite a bit slower 
> (roughly 2x).

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Jan 8 18:34:07 2010

This archive was generated by hypermail 2.1.8 : 2010-01-08 18:34:09 CET