Boost logo

Boost :

From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2007-08-12 19:43:20


On Aug 12, 2007, at 1:22 PM, Ion Gaztañaga wrote:

> John Maddock wrote:
>> The difference is that C++ lets you spot the duplication: for
>> example if you
>> discover that your application is using vector<int>,
>> vector<unsigned>,
>> vector<long> and vector<heaven-knows-what-else> then you should
>> definately
>> be asking why they can't all be using the same instantiation!
>
> Just a curiosity, Digginig in the Freescale/MSL STL implementation we
> use at job I've seen an space optimization MACRO (I don't know if it's
> activated by default or not) where all vectors of POD types of the
> same
> size where treated with a single type type (just the same trick as
> vector<void*> but with ints, shorts, and similar POD types). I suppose
> that option was there because the compiler was not smart enough to
> optimize them (I don't know if that's true nowadays).

It's been awhile since I looked at the most recent Freescale STL, but
last time I looked, this flag was on by default. This optimization
was originally written before the Freescale linker did code folding.
After the Freescale linker did code folding it appeared to me that the
two optimizations worked together synergistically. I.e. sometimes the
lib would catch stuff the linker missed and vice-versa.

Fwiw, it isn't an easy optimization in the lib to get right (I got it
wrong first time out of the gate). But it does seem worthwhile. I
had a major customer once tell me this optimization saved him 750Kb
code, and this was back when a Mb of code was a lot. ;-)

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk