[haiku-appserver] Re: [Haiku-commits] r14599 - haiku/trunk/src/servers/app

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Mon, 31 Oct 2005 23:35:17 +0100

On 2005-10-31 at 21:50:20 [+0100], Adi Oanca wrote:
[...]
>     What if we avoid programming with exceptions and compile the app_server
> without exceptions support? This should get us some speed...
> Is it possible?

It is possible, though. Whether it really gains a lot is another thing. AFAIK 
the overhead of using exceptions is not really relevant (if there is overhead 
at all -- you have to do error checking anyway). Throwing exceptions can be 
rather expensive, though, which is why one should use them only for really 
exceptional cases.

> > +            while (fDesktops.CountItems() > 0) {
> > +                Desktop *desktop = fDesktops.RemoveItemAt(0);
> ...
> > +            }
> > -                    Layer *layer;
> > -                    for (int32 i = 0; i < windowCount; ++i)
> > -                        // is this layer in fact a WinBorder?
> > -                        if ((layer = 
> > static_cast<Layer*>(sDesktop->WindowList().ItemAtFast(i)))) {
> ...
> > -                        }
> 
>     To avoid a few CPU cycles please pull out local declarations from loops.

Please don't do something like this; keeping variables as local as possible 
increases the readability. Furthermore trust the compiler. Don't try to trick 
it -- it's your friend. Extending the scope of a variable may cause a bigger 
stack footprint and may even make your code slower, since the compiler has 
less knowledge it can apply.

CU, Ingo

Other related posts: