Bug 137978 - Avoid repeated is<MutableStyleProperties>() checks in StyleProperties
Summary: Avoid repeated is<MutableStyleProperties>() checks in StyleProperties
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-22 12:30 PDT by Chris Dumez
Modified: 2014-10-22 14:16 PDT (History)
4 users (show)

See Also:


Attachments
Patch (11.27 KB, patch)
2014-10-22 12:38 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (11.34 KB, patch)
2014-10-22 13:31 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-10-22 12:30:53 PDT
We can reduce the amount of is<MutableStyleProperties>() checks in StyleProperties by removing the checks in each method of StyleProperties::PropertyReference, and replace them by a single check in StyleProperties::propertyAt().
We can also provide faster propertyCount() / propertyAt() / isEmpty() methods on MutableStyleProperties / ImmutableStyleProperties as a lot of callers use tight typing.
Comment 1 Chris Dumez 2014-10-22 12:38:10 PDT
Created attachment 240290 [details]
Patch
Comment 2 Andreas Kling 2014-10-22 13:27:41 PDT
Comment on attachment 240290 [details]
Patch

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

r=me!

> Source/WebCore/css/StyleProperties.cpp:114
> +        for (unsigned i = 0; i < immutableOther.propertyCount(); ++i)

I'd cache the propertyCount() in a local.
Comment 3 Chris Dumez 2014-10-22 13:28:55 PDT
Comment on attachment 240290 [details]
Patch

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

>> Source/WebCore/css/StyleProperties.cpp:114
>> +        for (unsigned i = 0; i < immutableOther.propertyCount(); ++i)
> 
> I'd cache the propertyCount() in a local.

In this case, I don't think there is a performance impact as it is inlined but OK, it is good practice.
Comment 4 Chris Dumez 2014-10-22 13:31:14 PDT
Created attachment 240292 [details]
Patch
Comment 5 WebKit Commit Bot 2014-10-22 14:16:46 PDT
Comment on attachment 240292 [details]
Patch

Clearing flags on attachment: 240292

Committed r175067: <http://trac.webkit.org/changeset/175067>
Comment 6 WebKit Commit Bot 2014-10-22 14:16:51 PDT
All reviewed patches have been landed.  Closing bug.