Path: utzoo!attcan!uunet!husc6!mailrus!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: terminfo Keywords: terminfo, curses Message-ID: <13591@mimsy.UUCP> Date: 16 Sep 88 15:03:07 GMT References: <508@altos86.UUCP> <10544@ulysses.homer.nj.att.com> <1389@zen.co.uk> <3194@pegasus.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 25 In article <3194@pegasus.UUCP> hansen@pegasus.UUCP (Tony L. Hansen) writes: >A two byte match done with && is considerably faster than calling strcmp(). >Both abort as soon as a match fails and the first is done without the >overhead of a function call. The second is often done without the overhead of a function call, too. If the compiler will not expand strcmp in line, in time-sensitive code I just use a macro, or compare the first characters directly. >Parsing the data file is not the only problem with termcap, however. The >algorithm for searching for a given capability, after having parsed the >entire entry into memory, is an n^2 algorithm. The search for each >capability starts over again at the very beginning of the entry. This need not be the case. One obvious solution is to sort the entries. Another, perhaps better, is to hash them: I imagine a simple hash based on the first character and the length of the capability would work quite well. Compiling is not necessarily wrong: after all, we do it all the time with other things. It is, however, an extreme approach, and ought to be considered carefully. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris