Re: "Goto statement considered superfluous" (was: If you were inventing C)
From: Howard Brazee (howard_at_brazee.net)
Date: 09/27/04
- Next message: Robert Wagner: "Re: ASA when using cobol"
- Previous message: Bob: "a history question"
- In reply to: Michael Mattias: "Re: "Goto statement considered superfluous" (was: If you were inventing C)"
- Next in thread: LX-i: "Re: "Goto statement considered superfluous" (was: If you were inventing C)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 27 Sep 2004 16:34:15 GMT
On 27-Sep-2004, "Michael Mattias" <michael.mattias@gte.net> wrote:
> > Is there a reason to shoot the person who writes the 1st version of this
> code,
> > saving 6 assembler moves per day?
>
> No, but I'd consider shooting the guy who wrote the second one, which does
> not terminate the lookup (EXIT PERFORM) when COMPARE-DAY =
> DAY-OF-WEEK(DAY-INDEX) and performs FOUND-ONE.
>
> Curious how sometimes the most obvious optimizations are those most easily
> missed.
I thought about that when I wrote this example - and decided that my point was
made better by leaving obvious ways to optimize the code without adding
significant obfuscation/cost.
It is interesting though that this "obvious" optimization is less obvious at
closer examination. I don't know how efficient the compiler is, for instance,
and I do know that adding an extra check does add some overhead. While my
assumption is the same as yours - it is obvious that coding an early exit is
more efficient than repeating the loop, I also see that 3 1/2 more iterations
isn't a big cost, and adding a comparison where a maintenance programmer might
make a mistake isn't quite as efficient as it looks.
Still, we both code for efficiency when the cost appears low.
- Next message: Robert Wagner: "Re: ASA when using cobol"
- Previous message: Bob: "a history question"
- In reply to: Michael Mattias: "Re: "Goto statement considered superfluous" (was: If you were inventing C)"
- Next in thread: LX-i: "Re: "Goto statement considered superfluous" (was: If you were inventing C)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|