[haiku-commits] Re: haiku: hrev44066 - src/apps/deskbar

  • From: "Adrien Destugues" <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 24 Apr 2012 19:47:36 +0200

Le Tue, 24 Apr 2012 19:39:37 +0200, Rene Gollent <anevilyak@xxxxxxxxx> a écrit:


2012/4/24 Pawel Dziepak <pdziepak@xxxxxxxxxxx>:
BList::CountItems is defined in a separate translation unit so
compiler does not know whether it the returns value of a member or a
random integer. In addition to that even if CountItems was defined in
the same translation unit (so that compiler would know what it does)
the member which value it returns could be changed by another thread
so it still wouldn't be safe for compiler to make such optimization.

Mea culpa then, I was under the impression gcc4.5/4.6 were smart
enough to detect that kind of situation.

4.7 brings more cross-module optimizations and might be able to figure it out. Since it is not defined in the .h file, there is no way to do this before link time (how would the compiler know what to inline ?)

And, we're still using gcc2; this won't work in debug mode when disabling optimizations, and so on. I think writing it out of the loop doesn't decrease readability that much (I actually find it better, as the for line gets shorter, avoiding linebreaks in the middle of it), and I generally don't thrust the compiler for things I can do as easily myself. If the compiler did figure everything out, we wouldn't need to write code at all ;)

--
Adrien.

Other related posts: