Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!darwin.sura.net!jvnc.net!gmd.de!Germany.EU.net!rrz.uni-koeln.de!unidui!math.fu-berlin.de!hrz.tu-chemnitz.de!wutcd From: wutcd@chemnitz.guug.de (Joerg Wunsch) Subject: Re: 386BSD's non-standard C library Message-ID: <wutcd.718395968@hadrian> Sender: bin@hrz.tu-chemnitz.de (Owner of all binaries) Organization: tu-chemnitz References: <1992Sep24.031603.21009@minyos.xx.rmit.oz.au> <wutcd.717452137@hadrian> <1992Oct04.090410.26720@am.sublink.org> Date: Tue, 6 Oct 1992 18:26:08 GMT Lines: 35 alex@am.sublink.org (Alex Martelli) writes: >... >I once benchmarked the is*() and to*() functions from ctype.h as macros >using table-lookup instead and got huge speedups... that was in some PC >C compiler long ago, but I believe a simple lookup will still be >superior to a comparison, if and addition, and you need only pay a >few hundred bytes (256 each for toupper(), tolower(), and is*() since >the latter can make do with 1 byte/char by using the bits as flags for >lowercase, uppercase, digit, etc, for example isalnum() will do the >lookup and & the flag byte with (ISLOWER|ISUPPER|ISDIGIT)). >-- Ooops, you are not right, i guess. The macros _and_ the functions all do a table lookup (btw: the tables are smaller, only 2 * (256 + 1) bytes; i.e. for each char + for EOF one byte for the is*()-flags, and one byte for to{upper,lower}() ). But the problem is still another: if i had a given string ``FOO'', it'd be obvious: tolower()ing it must result in ``foo'' - but i can write down this immediate without any function or macro calls:-) If i don't know which characters my string consists of, but my intent is to have all possible uppercase characters in lower case, i'd _always_ habe to test for isupper(). So why shouldn't do that the tolower() function/macro? ANNOUNCEMENT: my enhanced ctype(3) package is complete now. That would be especially of interest for European people. It is based on configur- able character classes as done in SVR3. I'm only awaiting the test re- port of an alpha tester before releasing it. Enjoy, J"org -- J"org Wunsch, TCD GmbH Dresden, R"ahnitzgasse 18, D-O-8060 Dresden \ ~.~. joerg_wunsch%bonnie@hadrian.hrz.tu-chemnitz.de \ ~ | ~ voice: +49-351-5965 137 \ ===