This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why not optimize _Destroy for non-standard allocators, too?


In stl_construct.h in gcc 4.1, _Destroy puts extra effort to check that
the standard allocator is used before optimizing for types that have
trivial destructors.

This behavior is described by the code comment:
   * Destroy a range of objects using the supplied allocator.  For
   * nondefault allocators we do not optimize away invocation of
   * destroy() even if _Tp has a trivial destructor.

In a benchmark that uses a custom allocator that reflects a large
application, we found over a 1% improvement after allowing the same
optimization for non-default allocators. For us, this speedup comes from
faster calls to vector::clear().

What's the intention for not optimizing this function for non-default
allocators?

Regards,

Thomas Kho


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]