[lkml]   [1999]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: goto's ???

> 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) {

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 ...
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 <>
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
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:51    [W:0.069 / U:4.216 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site