Path: utzoo!attcan!uunet!decwrl!mcnc!rti!trt From: trt@rti.rti.org (Thomas Truscott) Newsgroups: comp.lang.c Subject: Re: Comparing strings... Summary: "unsigned char" is rarely slower than "signed char" Message-ID: <4149@rtifs1.UUCP> Date: 25 Oct 90 14:52:32 GMT References: <11486@alice.att.com> <3343@idunno.Princeton.EDU> <1990Oct15.223716.10793@zoo.toronto.edu> Organization: Research Triangle Institute, RTP, NC Lines: 22 Some years ago, while working on a fast DES implementation, I discovered that: int i; unsigned char table[8]; i = table[0]; ran faster than the obvious "char table[8]" on VAX, Gould, MC680X0, and Convex. I was rather surprised by that. And it was as fast as "char table[8]" on all the other machines I tried (e.g. MIPS, SPARC). As a practical :-) example of this, the fastest VAX bitcount reported by Chris Torek can be sped up 30% just by declaring nbits[] unsigned. A strcmp() routine might take advantage of this with: while ((c = *(unsigned char *)p) != '\0' && c == *(unsigned char *)q) Of course one must be careful about lexical ordering. Perhaps there are exceptions, but I did not encounter any. I am sure the PDP-11 would be an exception, but there wasn't one handy! Tom Truscott