[webkit-dev] Lets use PassRefPtr for arguments less; lets use RefPtr for locals and data members more

Alexey Proskuryakov ap at webkit.org
Mon Jun 20 21:39:13 PDT 2011


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

> Here's a few benefits:
> 1. It makes the code more self-documenting. It clearly indicates that this function intends to take a reference to the item.
> 2. It is consistent with the rules for PassOwnPtr. It is nice to have one set of things in mind that are consistent.
> 3. Just like one shouldn't document a function based on who calls it because that may change, it makes sense to base the argument types on the how the function uses them not on the callers.

1 and 3 sound very closely related. Yet I'm not sure if they are good.

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.

As Maciej mentioned, eventually we may be able to get rid of PassRefPtr, and use C++0x move semantics. But applicability of move semantics also depends on how a function is called, not on what it is going to do with its arguments.

- WBR, Alexey Proskuryakov



More information about the webkit-dev mailing list