20.06.2011, в 21:55, David Levin написал(а):

> PassRefPtr is useful even if the function doesn't take any kind of ownership. 
> It's useful when callers want to get rid of ownership, and then they can do 
> that efficiently.
> 
> I don't understand this. How it is more efficient to pass ownership if a 
> function isn't taking ownership? It seems like passing in a raw pointer would 
> be the most efficient in this case.

As a concrete example, consider a callback function. It can take a reference to 
an object as an argument - the caller definitely no longer needs this object 
after calling it, while the function may or may not take ownership (in any 
sense of this word). In an extreme case, it will not look at its argument at 
all.

Similarly, a base class implementation of a virtual member function may not do 
anything with its argument, while derived objects will "take ownership". It's 
not easy to tell if any of the overrides do (or will in the future) take 
ownership. Yet it's easy to see if ownership is being passed away at call sites.

- WBR, Alexey Proskuryakov

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to