WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
102306
For single element arrays use the pointer into the CFDataRef instead of copying data
https://bugs.webkit.org/show_bug.cgi?id=102306
Summary
For single element arrays use the pointer into the CFDataRef instead of copyi...
Pratik Solanki
Reported
2012-11-14 17:41:48 PST
This is an optimization when USE(NETWORK_CFDATA_ARRAY_CALLBACK) is available. Generally, WebCore copies the data returned from CFNetwork into its own buffers once the resource is done loading. However, if the resource is cached, CFNetwork will return us a CFArrayRef with exactly 1 CFDataRef in it. In such a case, it might be beneficial to not copy the data and just use the byte pointer i.e. call CFDataGetBytePtr() and use that memory directly.
Attachments
Patch
(3.91 KB, patch)
2012-11-15 10:49 PST
,
Pratik Solanki
no flags
Details
Formatted Diff
Diff
Patch
(8.06 KB, patch)
2012-11-15 17:31 PST
,
Pratik Solanki
ap
: review+
Details
Formatted Diff
Diff
Be slightly nicer!
(2.35 KB, patch)
2012-11-16 17:00 PST
,
Pratik Solanki
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Pratik Solanki
Comment 1
2012-11-14 17:42:10 PST
<
rdar://problem/12267471
>
Pratik Solanki
Comment 2
2012-11-15 10:49:13 PST
Created
attachment 174487
[details]
Patch
Pratik Solanki
Comment 3
2012-11-15 12:55:20 PST
Comment on
attachment 174487
[details]
Patch Retracting. This needs another tweak.
Pratik Solanki
Comment 4
2012-11-15 17:31:12 PST
Created
attachment 174569
[details]
Patch
Alexey Proskuryakov
Comment 5
2012-11-15 17:38:02 PST
Comment on
attachment 174569
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=174569&action=review
Looks reasonable to me. Brady might want to have a look too, as he's been refactoring adjacent code.
> Source/WebCore/ChangeLog:22 > + (WebCore):
It is helpful to edit ChangeLogs to remove useless gunk like this. ChangeLogs are meant for human consumption, so anything you can do to make reading easier is a plus (but obviously, not hugely important for somethign trivial like this).
> Source/WebCore/platform/SharedBuffer.cpp:149 > + const char *buffer = singleDataArrayBuffer();
Star goes to the left.
> Source/WebCore/platform/cf/SharedBufferCF.cpp:144 > + return reinterpret_cast<const char *>(CFDataGetBytePtr(m_dataArray.at(0).get()));
Ditto.
Pratik Solanki
Comment 6
2012-11-16 12:39:45 PST
Thanks for the review. I'll commit with the changes suggested. I also had to change a variable name since the compiler got confused about buffer being a const char * and a member function.
Pratik Solanki
Comment 7
2012-11-16 12:47:47 PST
Committed
r134987
: <
http://trac.webkit.org/changeset/134987
>
Darin Adler
Comment 8
2012-11-16 14:51:15 PST
Comment on
attachment 174569
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=174569&action=review
> Source/WebCore/platform/SharedBuffer.cpp:151 > + const char *buffer = singleDataArrayBuffer(); > + if (buffer) > + return buffer;
This would be slightly nicer with the variable definition inside the if.
> Source/WebCore/platform/cf/SharedBufferCF.cpp:143 > + if (m_dataArray.size() == 1)
This would be slightly nicer as an early return.
Darin Adler
Comment 9
2012-11-16 14:52:08 PST
(In reply to
comment #6
)
> I also had to change a variable name since the compiler got confused about buffer being a const char * and a member function.
An alternate solution in cases like that is to use this->functionName syntax to call a member function that is shadowed by a same-named local variable. We like that because it lets us use the cleanest simplest names for both.
Pratik Solanki
Comment 10
2012-11-16 17:00:45 PST
Reopening to attach new patch.
Pratik Solanki
Comment 11
2012-11-16 17:00:46 PST
Created
attachment 174785
[details]
Be slightly nicer! Sounds good. Added a patch with the comments addressed
Brent Fulgham
Comment 12
2012-11-19 17:44:03 PST
Comment on
attachment 174785
[details]
Be slightly nicer! Since the Apple guys are on vacation, and you have executed the changes ap and Darin asked for, r=me.
WebKit Review Bot
Comment 13
2012-11-19 17:55:49 PST
Comment on
attachment 174785
[details]
Be slightly nicer! Clearing flags on attachment: 174785 Committed
r135221
: <
http://trac.webkit.org/changeset/135221
>
Pratik Solanki
Comment 14
2012-11-24 12:44:12 PST
Brent, thanks for the r+ and cq+. Marking this bug as fixed.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug