Performance vs. Structure

John Woods john at frog.UUCP
Wed Oct 11 05:28:00 AEST 1989


In article <81 at tessera.UUCP>, jtc at 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 at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu



More information about the Comp.lang.c mailing list