lkml.org 
[lkml]   [1999]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: goto's ???
Hello!

> this seems like an extra jmp statement to me (unless the compiler
> optimises it)

There's a significant difference between these two cases:

(1) if (error)
goto handle_error;
(2) if (error) {
do_handle_error;
}
Expecting a straight-forward compilation, the first one gets
compiled to:

Jump-if-error handle_error

but the second one to:

Jump-if-not-error tmp1
... handle the error here ...
Return
tmp1:
the code continues here

In the second case, you save a jump in an error handling path, but at expense
of adding a jump to the common code path which will be slower in common case.
Therefore (1) will give better assembly until someone teaches the compiler
to distinguish between common and uncommon paths and reorder the code itself.

On the other hand, I think that at many places in the kernel this speed
difference just doesn't matter, but there is also no need to rewrite the
code just to get rid of a goto at place where it's clear what it does.
Have a nice fortnight
--
Martin `MJ' Mares <mj@ucw.cz> http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"IBM = Inside Black Magic"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [from the cache]
©2003-2011 Jasper Spaans