[Webkit-unassigned] [Bug 42726] Refactor CSSSelector's destructor and make it inline.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 21 20:50:36 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=42726





--- Comment #8 from Hayato Ito <hayato at chromium.org>  2010-07-21 20:50:36 PST ---
Hi, Darin
Thank you for the review again.

(In reply to comment #4)
> (From update of attachment 62155 [details])
> This patch is great! Thanks for taking my suggestions.
> 
> I am not wholly happy with the use of the term "children" to mean the objects a selector owns. It's standard to do such a thing in a generic tree structure, but in this case neither "tag history" nor "simple selector" seems to be entirely like a child. But since I don't have better terminology to suggest, I guess you can stick with "children" unless you can think of something better.

I agree that 'children' is very confusing name.  I've changed the names like:
  deleteChildren -> deleteReachableSelectors
  releaseChildrenToBag -> releaseOwnedSelectorsToBag

That naming might be far better than using 'children', I guess. It is always difficult to come up with good naming for me:).

> 
> > +inline void CSSSelector::releaseChildrenToBag(CSSSelector* selector, CSSSelectorBag* bag)
> 
> This function could, and should, take a reference to the bag instead of a pointer.

Done. Thank you.

> 
> I don't see why this is a static member function that takes a CSSSelector* rather than a non-static member function. It would be easier to read as a normal member function.

Done. This was stupid mistake. Thank you.

> 
> > +        ~CSSSelector()
> > +        {
> > +            // We should avoid a recursive destructor call, which causes stack overflow
> > +            // if selectors are deeply nested.
> > +            if (m_hasRareData) {
> > +                if (!m_data.m_rareData)
> > +                    return;
> > +            } else if (!m_data.m_tagHistory)
> > +                return;
> > +            deleteChildren();
> > +        }
> 
> I find this comment confusing. The comment explains why we call deleteChildren instead of just calling delete directly on the objects we own, but readers of the comment probably can't figure that out. Also, the comment is above the if statement, which has a different explanation: It's optimizing the common case where the selector does not own any pointers it needs to delete.
> 

Done. I updated the comments. Thank you.

> Since this is a refactoring patch, review- so you can fix the comment and the static member function.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list