
On Wed, 14 Jul 2004, MenTaLguY wrote:
On Wed, 14 Jul 2004, Aubanel MONNIER wrote:
Does the inkscape code already uses smart pointers somewhere ?
No.
glibmm does provide a smart pointer class which will have to be used with some gtkmm classes.
Since we will not be switching the entire codebase to garbage collection at once, we could conceivably use that, or write our own (smart pointer classes are simple, and I don't like the method names imposed by glibmm's).
On the other hand, I don't like smart pointers so much because they tend to impose additional reference counting overhead and then hide it; it's very easy for your performance to die a death of a thousand cuts if you use them pervasively[1].
-mental
[1] Some algorithms are implemented most efficiently using pointer assignment. Unless your smart pointer class provides means to "unwrap" the bare pointer underneath (glibmm's does not), you pay must pay the following costs for each assignment:
a. simple overhead for dereferencing the pointer and updating the reference count
b. cache effects from updating the reference count (probably negligible in most cases, since you're likely working with the object in question anyway)
c. if you care about threads, locking overhead to protect the reference count