soundex algorithm wanted

karl at haddock karl at haddock
Tue Sep 9 07:16:00 AEST 1986


umcp-cs!chris (Chris Torek) writes:
>In article <1239 at whuxl.UUCP> mike at whuxl.UUCP (BALDWIN) writes:
>>       register char   c, lc, prev = '0';
>All the compilers I have used ignore the `register' on `register char'
>declarations.

Well, the compilers I've used will put it in a register, but do extra work
(usually unnecessary) to clear the higher bits.  This is unfortunate.

>Is there ever any reason to declare a variable `register char' rather than
>`register int'?

If the range of the variable really is char (so EOF is excluded), then it
logically should be declared char.  I find it distasteful to write something
I don't mean just because it's more efficient than what I'd like*.  If the
machine has some one-byte registers available, `register char' is clearly a
good idea (assuming the compiler has any brains).  If the machine has only
full-word registers but allows byte access to them, `register char c0, c1,
c2, c3' could be packed into a single register; even on a VAX there are some
situations where the packing/unpacking cost is negligible (for non-numerical
usage, e.g.), and it saves on registers.  I don't know of any machines that
do this.

Karl W. Z. Heuer (ima!haddock!karl; karl at haddock.isc.com), The Walking Lint
*Like the keyword `register' itself, which is a crutch for dumb compilers.



More information about the Comp.lang.c mailing list