[MLton-devel] Int-inf shifts

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Fri, 1 Nov 2002 09:10:01 -0500 (EST)


> > If anyone is
> > worried about speed, we could wrap the for-loop inside an if (base > 10)
> > condition, so all but hex formatting would not require the extra walk.
> 
> Why not.

O.k. -- the base check is in the code.

> Ye gods, what is the reason for the cryptic
>       sp->chars[i] = c - ' ';
> Why not the more understandable
>       sp->chars[i] = c + 'A' - 'a';
> (Either way it depends on ASCII, but the latter only requires a fixed delta
> for all upper or lower case characters, not the pun that this delta happens
> to be the same as the encoding for a space.)
> Sorry, but even C doesn't have to be that cryptic.

O.k. -- I used the ('A' - 'a') expression.  

Now the loop looks like:

        if (base > 0)
		for (i = 0; i < size; i++) {
			c = sp->chars[i];
			if (('a' <= c) && (c <= 'z'))
				sp->chars[i] = c + ('A' - 'a');
		}

and is checked into the basis-2002 branch.



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel