[comp.lang.c] Performance vs. Structure

jtc@tessera.UUCP (J.T. Conklin) (10/07/89)

I've been amused as various people have "Structured" the _doprnt
code by eliminating gotos.  I don't get it.  Is it really worth
increasing the formatted i/o bottleneck by eliminating gotos from
a library routine that may not be changed in years?

I don't advocate gratuitious use of gotos, but I find them perfectly
acceptable in low-level library routines and small state machines.

    --jtc

-- 
J.T. Conklin
	...!{ubc-cs,uunet}!van-bc!tessera!jtc

john@frog.UUCP (John Woods) (10/11/89)

In article <81@tessera.UUCP>, jtc@tessera.UUCP (J.T. Conklin) writes:
> I've been amused as various people have "Structured" the _doprnt
> code by eliminating gotos.  I don't get it.  Is it really worth
> increasing the formatted i/o bottleneck by eliminating gotos from
> a library routine that may not be changed in years?
> 
As someone who has recently FIXED a _doprnt equivalent, I'd say that
increasing clarity (by eliminating gotos if necessary) is worth it
for any subroutine with any possibility of error.  Gotos are certainly
not EVIL by nature, but some twisted hack that shaves one microsecond
off of every 17th invocation of a complicated subroutine may cause nightmares
for the poor soul who has to then SPEND YEARS trying to understand just
WHY it does something stupid every 91st invocation.  (The converse is
true, by the way:  if a goto can increase the clarity of a routine, go
for it.  Just be _real_ sure that it is an improvement...)

You may not THINK it will be changed in years.  Your successor may come after
you with a baseball bat if you code with that in mind.
-- 
John Woods, Charles River Data Systems, Framingham MA 508-626-1101
...!decvax!frog!john, john@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu