[haiku-commits] Re: haiku: hrev46398 - src/apps/serialconnect

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 20 Nov 2013 20:13:16 -0500

On 11/20/13, Urias McCullough <umccullough@xxxxxxxxx> wrote:
> class BFilePanel;
>
> under the class BMenu; instead?

Well, above since we sort them alphabetically, but yes. For reference,
the reason is that a forward declaration is much faster for the
compiler to handle than loading/parsing the full header. This problem
is exacerbated when including a header in another header, since that
then further penalizes any other file including the header in
question. In this particular instance, it's not as big of an issue
since there are only one or two other files that include
SerialWindow.h, but for e.g. a header in headers/private/shared, or a
public header, the impact is quite noticeable for build times.

There are cases where it's unavoidable due to needing the full type
definition. In this particular instance the forward declaration
suffices since SerialWindow just declares a BFilePanel*, and the size
of all pointers is the same, so all the compiler needs to know is that
BFilePanel is a valid type. If the member had simply been a BFilePanel
(non-pointer) instead, then the full include would indeed be
necessary, as the compiler would then need to know the full definition
of BFilePanel in order to compute its size, as that then needs to be
accounted for when computing the size of the enclosing class.

Regards,

Rene

Other related posts: