Ref-counting, smart ptrs, and COW (was: Re: Cppcheck: false positive in pptx-text.cxx ?)

Thorsten Behrens thb at documentfoundation.org
Wed Jan 23 12:53:58 PST 2013


Eike Rathke wrote:
> On Sunday, 2013-01-20 19:55:17 +0100, Markus Mohrhard wrote:
> > Someone implemented here manualy ref counting. If you want to remove
> > the warning you can replace the raw pointer + the ref counting
> > variable with a  boost::shared_ptr.
> 
> While boost::shared_ptr is of course cleaner code, for mass objects it
> may add a runtime performance penalty if they are passed around a lot.
> For example I wouldn't change formula tokens to shared_ptr ...
> 
Yeah, because of atomic counters, and because of extra memory
allocations. Here's some background on various kinds of smart ptrs:

 http://www.boost.org/doc/libs/1_35_0/doc/html/interprocess/interprocess_smart_ptr.html

As an aside, for a number of basegfx objects, copy-on-write semantics
are implemented via o3tl/inc/o3tl/cow_wrapper.hxx - see
e.g. basegfx/inc/basegfx/tools/b2dclipstate.hxx for a simple
example. At least for vcl stuff like Bitmaps, this template could be
used instead of the hand-rolled versions.

Cheers,

-- Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130123/b5ea670b/attachment.pgp>


More information about the LibreOffice mailing list