
8 Dec
2010
8 Dec
'10
7:13 p.m.
On Saturday 04 December 2010 20:46:49 Peter Foelsche wrote:
I wrote a couple of lines and replaced std::set and std::map with some copy-on-write-wrappers and I got a dramatic speed improvement with the last gcc 4.5. I think.
My code was using recursive functions iterating over a tree returning and setting such objects.
I looked and it seems there is nothing like this in boost!
Automatic COW is often generating too much overhead. Using objects you only explicitly clone when you need a modifyable copy can be beneficial though, and there is a very simple way to achieve both: Use a shared_ptr<T const> for the shared, immutable object and an auto_ptr<T> for the unshared, mutable one. Uli