Bug 98683 - SVGResources should use HashSet<AtomicString> instead of HashSet<AtomicStringImpl*>
Summary: SVGResources should use HashSet<AtomicString> instead of HashSet<AtomicString...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Florin Malita
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-08 13:37 PDT by Eric Seidel (no email)
Modified: 2012-10-09 11:36 PDT (History)
6 users (show)

See Also:


Attachments
Patch (10.95 KB, patch)
2012-10-09 08:19 PDT, Florin Malita
no flags Details | Formatted Diff | Diff
Patch for landing (10.94 KB, patch)
2012-10-09 10:58 PDT, Florin Malita
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2012-10-08 13:37:36 PDT
SVGResources should use HashSet<AtomicString> instead of HashSet<AtomicStringImpl*>

They do basically the same thing, and the former is much more common (and less code).  It's also safe, on the off-chance that we're using AtomicStrings which might otherwise go away.
Comment 1 Florin Malita 2012-10-09 08:19:33 PDT
Created attachment 167759 [details]
Patch
Comment 2 Darin Adler 2012-10-09 10:05:20 PDT
Comment on attachment 167759 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=167759&action=review

> Source/WebCore/rendering/svg/SVGResources.cpp:205
> +    AtomicString tagName = element->tagQName().localName();

This adds a bit of reference count churn. If we know that the element won’t be deleted while we’re working on it, we could use const AtomicString& as the type instead.

> Source/WebCore/rendering/svg/SVGResources.cpp:206
> +    if (tagName.isEmpty())

I think we only need an isNull check here. An isEmpty check is both more expensive than a null check, and also may not be correct since the old code did a null check. I wonder if we have test coverage for the empty string case?
Comment 3 Eric Seidel (no email) 2012-10-09 10:25:46 PDT
Comment on attachment 167759 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=167759&action=review

>> Source/WebCore/rendering/svg/SVGResources.cpp:205
>> +    AtomicString tagName = element->tagQName().localName();
> 
> This adds a bit of reference count churn. If we know that the element won’t be deleted while we’re working on it, we could use const AtomicString& as the type instead.

Also, I think you can just call element->localName() directly and don't have to go through the qname?
Comment 4 Florin Malita 2012-10-09 10:58:25 PDT
Thanks for reviewing, updated.

(In reply to comment #2)
> > Source/WebCore/rendering/svg/SVGResources.cpp:205
> > +    AtomicString tagName = element->tagQName().localName();
> 
> This adds a bit of reference count churn. If we know that the element won’t be deleted while we’re working on it, we could use const AtomicString& as the type instead.

Done.


> > Source/WebCore/rendering/svg/SVGResources.cpp:206
> > +    if (tagName.isEmpty())
> 
> I think we only need an isNull check here. An isEmpty check is both more expensive than a null check, and also may not be correct since the old code did a null check. I wonder if we have test coverage for the empty string case?

Good point, should avoid changing behavior here. Even if it's possible to get an empty tag name here, it shouldn't have any impact as it will just skip through the remaining conditionals and return false. Updated.

(In reply to comment #3)
> Also, I think you can just call element->localName() directly and don't have to go through the qname?

Done.
Comment 5 Florin Malita 2012-10-09 10:58:48 PDT
Created attachment 167786 [details]
Patch for landing
Comment 6 WebKit Review Bot 2012-10-09 11:36:13 PDT
Comment on attachment 167786 [details]
Patch for landing

Clearing flags on attachment: 167786

Committed r130780: <http://trac.webkit.org/changeset/130780>
Comment 7 WebKit Review Bot 2012-10-09 11:36:16 PDT
All reviewed patches have been landed.  Closing bug.