[Mesa-dev] [PATCH v2 12/15] nv50/ir: optimize the use of std::tr1::unordered_set

Ilia Mirkin imirkin at alum.mit.edu
Wed May 20 09:10:58 PDT 2015

On Wed, May 20, 2015 at 9:52 AM, Francisco Jerez <currojerez at riseup.net> wrote:
> Ilia Mirkin <imirkin at alum.mit.edu> writes:
>> Francisco, any opinion on this patch (as the resident C++ expert)? It
>> seems a little odd. I'd just as soon skip this, and just use "using
>> std::tr1::unordered_set" or "using std::unordered_set" as necessary in
>> the next patch. But perhaps this is a common technique?
> This seems really ugly to me.  I've given the patch a try and the single
> instantiation that this patch saves is some 2.7 kB of the binary, some
> 0.1% of the size of nouveau_compiler alone and 0.03% of the size of the
> DRI driver with my configuration.  IMHO the tiny saving in disk space
> hardly justifies the additional complexity and giving up the type-safe
> interface provided by the STL (except for the begin() and end() methods
> you have overridden with correct types, which is a tiny fraction of the
> unordered_set interface).

Thanks for confirming what I suspected -- this isn't a common way to
do things, and is not hugely beneficial (otherwise it'd be a common
way to do things, and/or the stl impl would do something clever to get
this sort of effect).

> If this is required for compatibility reasons with old Android systems I
> suggest you wrap it under a preprocessor conditional like:
> #if __cplusplus >= 201103L
> using std::unordered_set;
> #elif building-on-old-android-version-with-broken-stlport
> using my-funky-wrapper-for-std-unordered-set;
> #else
> using std::tr1::unordered_set;
> #endif

Chih-Wei, I think this is the right way to go as well. Could you
rework your nv50/ir patches into one that does it this way? Sounds
like the "#elif funky-wrapper" bit isn't actually needed anymore
either, as you're going with a C++11-only approach?



More information about the mesa-dev mailing list