Hi
On Sat, May 05, 2007 at 11:14:11PM +0200, Guillaume Poirier wrote:
> Hi,
>> On May 5, 2007, at 10:35 , Michael Niedermayer wrote:
>> > On Sat, May 05, 2007 at 10:08:25AM +0200, Guillaume Poirier wrote:
> >> On May 5, 2007, at 3:00 , Rich Felker wrote:
> >>> On Sat, May 05, 2007 at 12:57:35AM +0100, Robert Swain wrote:
> >>>> Out of personal interest and being a lesser experienced programmer,
> >>>> I've always been lead to believe that 'goto' shouldn't be used
> >>>> unless
> >>>> absolutely necessary. Grepping the FFmpeg source throws up far more
> >>>> results than I expected so now I'm wondering - why have you
> >>>> suggested
> >>>> the use of goto over something like a 'while' loop? If it's
> >>>> better to
> >>>> use a goto in some cases, I'd like to know when and why. :)
> >>>
> >>> This is nonsensical dogma. Continue and break statements are exactly
> >>> the same thing as goto. Use whatever control construct makes
> >>> sense to
> >>> the code you're writing. Inserting dummy loops so you can break just
> >>> to "hide" your goto in a break statement is ridiculous. If you mean
> >>> goto, say goto.
> >>>
> >>> FWIW, goto is extremely useful for error case handling can cleanup
> >>> before error returns.
> >>
> >> It's maybe useful for the programmer, but it confuses compilers so
> >> that some optimization passes can't be performed on a code with
> >> goto's.
> >> Well, maybe not all compilers are like this, but i bet it confuses
> >> GCC, who's not the smartest compiler around...
> >
> > ffmpeg contains a few gotos, can you point to one where the code
> > would be
> > faster without the goto?
>> I'll try my best to gather this information for you. I was merely
> repeating what one of our corporate in-house genius has told me to
> explain why GOTO are evil. I'm now convinced that they should really
> be avoided in all cases.
such dogmas (like all gotos should be avoided, never overload operators,
never directly access fields of objects but rather use set/get methods, ...)
are complete utter nonsense
its rather that you should write clean/readable/maintainable/fast/... code,
and this can often be done better without goto than with goto but there
are cases where its better with goto and in these cases goto should be used
also operator overloading is very usefull for math related structs, and
thinking of java set/get shit makes me feel like i have to vomit
either way, if you can improve the speed od libavcodec by removing gotos
that would be great, also goto is used in speed critical code, like the
block decoding in some mpeg based codecs ...
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070506/2be0cea0/attachment.pgp>