[geos-devel] How to make compilation time shorter
strk at refractions.net
strk at refractions.net
Mon Mar 6 04:26:17 EST 2006
I'm all for the refactoring.
C++ API users should include the geos.h file, anyway,
so we can provide the same definition from it by including
the splitted headers.
Also, I've been experimenting the use of a separate file
for class inlines. So far we only have LineSegment.inl but
the idea is to use a file for each class with inline elements.
The advantage of this is we can switch between inlined and
non-inlined versions by defining an USE_INLINE macro.
This way, developers can use the non-inlined version to make
build time faster when changing inline funx bodies.
Next candidate for this would be Coordinate.
--strk;
On Mon, Mar 06, 2006 at 12:15:57AM +0100, Mateusz Å?oskot wrote:
> Hi,
>
> GEOS compilation time is quite long.
> Some days ago, I was talking about it with strk and we compared how long
> does it take with GCC vc VC++.
> The time varies from 3 to a few tens of minutes (strk can say what's the
> latter value).
>
> Today, I was working on Unit Tests and I noticed that geom.h file
> defines all geometry classes and then it's included in (almost) every
> .cpp file.
>
> And if I apply small change to geom.h, e.g. Envelope class then it will
> require almost complete rebuild of GEOS to update binaries.
> It really slows down development.
>
> I'd suggest to refactor the source code that every class is splitted
> into separate .h/.cpp file. geom.h would be the first candidate :-)
>
> So, then envelope.cpp could include *only* envelope.h file.
> If something in envelope.h is changed then it will required to recompile
> envelope.cpp file + files that include envelope.h.
>
> This second group of files could be yet refactored to minimize
> compile-time dependencies, according to some of Herb Sutter's suggestions:
> http://www.gotw.ca/gotw/007.htm
>
> Short example:
>
> // a.cpp file
> #include "envelope.h"
> struct A
> {
> Envelope* pe;
> void foo(Envelope* e);
> };
>
> In the example above we can safely remove #include "envelope.h" because
> compiler does not need here definition of Envelope class.
> We can replace #include "envelope.h" with forward declaration:
>
> // a.cpp file
>
> class Envelope;
>
> struct A
> {
> Envelope* pe;
> void foo(Envelope* e);
> };
>
> After more such cases would be refactored, then compilation time should
> be significantly shorter. So, development could run faster :-)
>
> What is your opinion?
>
> Cheers
> --
> Mateusz Åoskot
> http://mateusz.loskot.net
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
--
----------------------------------------------------------------------
State-collected Geographic Data is public property !
Reject the INSPIRE directive.
Sign the petition: http://petition.publicgeodata.org
More information about the geos-devel
mailing list