Date: Sat, 09 Sep 1995 10:23:39 -0700 From: Paul Traina <pst@shockwave.com> To: Wolfram Schneider <wosch@freebsd.first.gmd.de> Cc: current@FreeBSD.ORG Subject: Re: 20-40% faster wc(1) Message-ID: <199509091723.KAA00756@precipice.shockwave.com> In-Reply-To: Your message of "Sat, 09 Sep 1995 14:04:54 %2B0159." <199509091205.OAA18842@freebsd.first.gmd.de>
next in thread | previous in thread | raw e-mail | index | archive | help
I don't understand... the original isspace() was just a lookup in a table followed by an 'and'. I assume this changed because of the rune code? The question you should be asking yourself is WHY is isspace(3) slow? Not kludging wc. I do not think this patch should be accepted. Paul From: Wolfram Schneider <wosch@freebsd.first.gmd.de> Subject: 20-40% faster wc(1) --- 1.1 1995/09/09 11:30:35 +++ Makefile 1995/09/09 11:34:03 @@ -1,5 +1,6 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= wc +CFLAGS+= -DOPT .include <bsd.prog.mk> --- 1.1 1995/09/09 11:30:35 +++ wc.c 1995/09/09 11:33:01 @@ -122,6 +122,14 @@ struct stat sb; int fd; u_char buf[MAXBSIZE]; +#ifdef OPT + u_char spbuf[256]; /* buffer for isspace lookup */ + + for (ch = 0; ch < 256; ch++) + spbuf[ch] = isspace(ch); +#define ISSPACE(x) spbuf[x] +#endif + fd = STDIN_FILENO; linect = wordct = charct = 0; @@ -183,7 +191,11 @@ ch = *p++; if (ch == '\n') ++linect; - if (isspace(ch)) +#ifdef OPT + if (ISSPACE(ch)) +#else + if (isspace(ch)) +#endif gotsp = 1; else if (gotsp) { gotsp = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199509091723.KAA00756>