[PATCH] debloat lash by 4.803725881571%

Rich Felker dalias at aerifal.cx
Tue Jun 20 20:51:04 UTC 2006


On Tue, Jun 20, 2006 at 10:14:24PM +0200, Bernhard Fischer wrote:
> >> >Why do you do this sort of thing repeatedly?
> >> >
> >> >-				while(isalnum(*src) || *src=='_') src++;
> >> >+				while((isalnum)(*src) || *src=='_') src++;
> >>
> >> It's smaller to call the function in these places. It's not always
> >> smaller to use the function as opposed to inlining the code via the
> >> macro.
> >
> >If it's smaller to call the function then we should beat on the headers to 
> >make the macro go away in platform.h.  That's one of the reasons for moving 
> >headers into libbb.h; so we can override what they do.
> 
> I had a patch which did exactly this (see "Subject:.*ctype.*" this
> month) and you loudly objected and said that you don't ... care about
> it. I'm using this patch in my local tree, i fine-tuned it a bit more so
> it saves even a tad more for me.
> 
> Oh, and note that i said "It's not always smaller to use the function",
> so there is no catch-them all switch to tune these, at least AFAICS.

BTW a function call may be smaller for isalnum, but isalpha is so
trivial that it should always be smaller as a macro:

#define isalpha(x) (((unsigned)(x) | 0x20)-'a' < 26)

Dunno about other archs but on i386 that should compile to 4
instructions (or, sub, sub, j[cc]). If you don't care about rejecting
out-of-range values make the cast (unsigned char) and the code should
get even smaller.

Rich




More information about the busybox mailing list