terminfo

Chris Torek chris at mimsy.UUCP
Sat Sep 17 01:03:07 AEST 1988


In article <3194 at pegasus.UUCP> hansen at 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 at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list