[BusyBox] Today's ash improvements

Aaron Lehmann aaronl at vitelus.com
Sat Aug 4 10:59:09 UTC 2001


On Sat, Aug 04, 2001 at 07:40:38PM +0400, Vladimir N. Oleynik wrote:
> > 1) is_digit() uses only one comparison now. ((c)>='0' && (c)<='9') was
> > replaced with ((unsigned)(c) - '0' <= 9). Neat trick, eh?
> 
> Such optimization certainly works, under condition of certainly, that we use
> one-byte char.
> But I do not like such approach.

What if we explicitly cast the argument to a char first, or redefine
the macro as an inline function accepting a char?

> > 2) The 257 byte is_type table was replaced by a few simple tests.
> > is_special was changed from ((is_type+SYNBASE)[c] & (ISSPECL|ISDIGIT))
> > to (is_digit(c)||c=='!'||c=='#'||c=='$'||c=='*'||c=='-').
> 
> You have missed two more symbols: '?' and '@'.
> But idea your excellent.

!@$%#$

You're right. Thanks. I need to be less lazy and write scripts to do
this sort of thing for me so I don't make dumb mistakes.

> > 3) tokendlist was changed from a 30 byte array of booleans (chars) to
> > a 30 bit bitmask.
> 
> This optimization takes into account, that position and quantity tokens will not
> change.
> Look my variant. In the sum we receive a prize in 300 bytes without loss of an
> opportunity
> to correct the tokens table.

I like your version. It makes things much cleaner.

But I have a better idea.

How about we reorder the tokens so that the ones that can "end a list"
come first? Then we can just check if the token is <= the last token
that ends a list (which would be a #define). Do you like it?





More information about the busybox mailing list