[webkit-dev] "maintenance" to do list

Darin Adler darin at apple.com
Wed Feb 13 10:41:58 PST 2008


On Feb 13, 2008, at 10:31 AM, Chris Brichford wrote:

> I'd suggest that ref/deref classes start out with a 0 ref count, but  
> all their constructor and destructors should protected or private.   
> The concrete classes that should be "constructable" should then have  
> a static method that calls the constructor and returns a  
> PassRefPtr.  Such an approach makes it harder to misuse the class.   
> It would also simplify the RefPtr and PassRefPtr classes because  
> their constructors that accept a raw ptr would *always* call ref.
>
> Even if the ref/deref classes start out with a 1 ref count, it still  
> would make sense to me to make the constructors and destructors  
> protected or private such that a static method on the class  
> encapsulates the incantation to get a RefPtr or PassRefPtr to a new  
> instances of the class.

Completely agreed. That's how we're doing it. Starting with a ref.  
count of 1 gives a performance boost and making a create function that  
returns a PassRefPtr makes using the class more foolproof. Here's an  
example I checked in this weekend:

     <http://trac.webkit.org/projects/webkit/changeset/30109>

Note that the constructors are private, the create functions are  
public, and due to the use of adoptRef it starts at 1, rather than  
starting at 0 and then being bumped to 1.

I'll mention it on the maintenance page.

     -- Darin



More information about the webkit-dev mailing list