Patchwork [v3] Tweak _Result_alloc to exploit the Empty Base Optimization

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 8, 2010, 8:29 p.m.
Message ID <4CAF7F1B.30500@oracle.com>
Download mbox | patch
Permalink /patch/67279/
State New
Headers show

Comments

Paolo Carlini - Oct. 8, 2010, 8:29 p.m.
Hi,

tested x86_64-linux, committed to mainline.

Paolo.

//////////////////////////
2010-10-08  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/future (_Result_alloc): Derive from _Alloc,
	exploit the Empty Base Optimization.

Patch

Index: include/std/future
===================================================================
--- include/std/future	(revision 165193)
+++ include/std/future	(working copy)
@@ -215,24 +215,22 @@ 
 
     /// Result_alloc.
     template<typename _Res, typename _Alloc>
-      struct _Result_alloc : _Result<_Res>
+      struct _Result_alloc : _Result<_Res>, _Alloc
       {
         typedef typename _Alloc::template rebind<_Result_alloc>::other
           __allocator_type;
 
         explicit
-	_Result_alloc(const _Alloc& __a) : _Result<_Res>(), _M_alloc(__a)
+	_Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a)
         { }
 	
       private:
 	void _M_destroy()
         {
-          __allocator_type __a(_M_alloc);
+          __allocator_type __a(*this);
           __a.destroy(this);
           __a.deallocate(this, 1);
         }
-
-        __allocator_type _M_alloc;
       };
 
     template<typename _Res, typename _Allocator>