From 04040ae5662bf89d8dfa56a5e587fc6dc7f975bc Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 28 Apr 2008 14:11:46 +0000 Subject: [PATCH] Improve documentation on the size/efficiency of boost::function objects [SVN r44852] --- doc/misc.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/misc.xml b/doc/misc.xml index 840605d..ef0906c 100644 --- a/doc/misc.xml +++ b/doc/misc.xml @@ -24,7 +24,7 @@ And, of course, function pointers have several advantages over Boost.Function: - Function pointers are smaller (the size of one pointer instead of three) + Function pointers are smaller (the size of one pointer instead of four or more) Function pointers are faster (Boost.Function may require two calls through function pointers) Function pointers are backward-compatible with C libraries. More readable error messages. @@ -37,12 +37,12 @@
Function object wrapper size - Function object wrappers will be the size of two function pointers plus one function pointer or data pointer (whichever is larger). On common 32-bit platforms, this amounts to 12 bytes per wrapper. Additionally, the function object target will be allocated on the heap. + Function object wrappers will be the size of a struct containing a member function pointer and two data pointers. The actual size can vary significantly depending on the underlying platform; on 32-bit Mac OS X with GCC, this amounts to 16 bytes, while it is 32 bytes Windows with Visual C++. Additionally, the function object target may be allocated on the heap, if it cannot be placed into the small-object buffer in the boost::function object.
Copying efficiency - Copying function object wrappers may require allocating memory for a copy of the function object target. The default allocator may be replaced with a faster custom allocator or one may choose to allow the function object wrappers to only store function object targets by reference (using ref) if the cost of this cloning becomes prohibitive. + Copying function object wrappers may require allocating memory for a copy of the function object target. The default allocator may be replaced with a faster custom allocator or one may choose to allow the function object wrappers to only store function object targets by reference (using ref) if the cost of this cloning becomes prohibitive. Small function objects can be stored within the boost::function object itself, improving copying efficiency.