Bug 12401 - Avoid unnecessary allocations in CSS
Summary: Avoid unnecessary allocations in CSS
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2007-01-24 16:54 PST by Beth Dakin
Modified: 2007-01-26 09:29 PST (History)
1 user (show)

See Also:


Attachments
Nate's patch (2.13 KB, patch)
2007-01-24 16:56 PST, Beth Dakin
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Beth Dakin 2007-01-24 16:54:35 PST
From <rdar://problem/4946877>

* SUMMARY
Patch attached which avoids several unnecessary allocations, cutting down on time in malloc and free.

1. css/MediaQueryEvaluator.cpp, css/MediaQueryEvaluator.h, css/cssstyleselector.cpp

Add a special method to the MediaQueryEvaluator class to avoid unnecessary turning a char * into a String object.  

2. loader/Cache.cpp

Don't turn a KURL's underlying String into another identical KURL.  Or, even better, you could change the prototype to createResource to just take a String& instead of a KURL& and pass the url.url() to that, which is what createResource really wants to be doing anyway (since it only ever uses the String), but is no less work.
Comment 1 Beth Dakin 2007-01-24 16:56:00 PST
Created attachment 12655 [details]
Nate's patch

Here is the patch attached to the radar bug.
Comment 2 Darin Adler 2007-01-24 16:59:13 PST
Comment on attachment 12655 [details]
Nate's patch

Looks good. r=me
Comment 3 Maciej Stachowiak 2007-01-24 17:12:27 PST
I don't think change #2 will actually save any allocations, since creating a KURL from the DeprecatedString inside another KURL won't actually call malloc. It will needlessly reparse it though, so still a good change. This needs a ChangeLog and should be run through regression tests.
Comment 4 Darin Adler 2007-01-26 09:29:47 PST
I ran the regression tests and wrote a change log.

Committed revision 19156.