Bug 119390 - Remove dependency on CoreFoundation from WebURLResponse
Summary: Remove dependency on CoreFoundation from WebURLResponse
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows 7
: P2 Normal
Assignee: Patrick R. Gansterer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-01 04:59 PDT by Patrick R. Gansterer
Modified: 2013-08-07 00:18 PDT (History)
3 users (show)

See Also:


Attachments
Patch (1.54 KB, patch)
2013-08-01 05:00 PDT, Patrick R. Gansterer
no flags Details | Formatted Diff | Diff
Patch (1.68 KB, patch)
2013-08-05 14:41 PDT, Patrick R. Gansterer
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick R. Gansterer 2013-08-01 04:59:01 PDT
Remove dependency on CoreFoundation from WebURLResponse
Comment 1 Patrick R. Gansterer 2013-08-01 05:00:10 PDT
Created attachment 207913 [details]
Patch
Comment 2 Brent Fulgham 2013-08-02 08:53:54 PDT
Comment on attachment 207913 [details]
Patch

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

This is really more a renaming than actually removing a dependency (I guess the CFIndex type definition might have forced a CoreFoundation reference).  Looks fine to me.  Was there a CoreFoundation include that could be removed here as well?

> Source/WebKit/win/WebURLResponse.cpp:375
> +    String statusText = localizedShortDescriptionForStatusCode(statusCode);

Seems like this could be "const String& statusText" = ...; might allow return-value-optimization.
Comment 3 Patrick R. Gansterer 2013-08-02 09:53:00 PDT
Comment on attachment 207913 [details]
Patch

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

>> Source/WebKit/win/WebURLResponse.cpp:375
>> +    String statusText = localizedShortDescriptionForStatusCode(statusCode);
> 
> Seems like this could be "const String& statusText" = ...; might allow return-value-optimization.

but then i need to change the whole function implementation, do you think it makes sense for this function? imho it's not called so often...
Comment 4 Brent Fulgham 2013-08-02 10:27:35 PDT
Comment on attachment 207913 [details]
Patch

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

>>> Source/WebKit/win/WebURLResponse.cpp:375
>>> +    String statusText = localizedShortDescriptionForStatusCode(statusCode);
>> 
>> Seems like this could be "const String& statusText" = ...; might allow return-value-optimization.
> 
> but then i need to change the whole function implementation, do you think it makes sense for this function? imho it's not called so often...

What? Why?  Does the BString constructor want a non-const String argument?
Comment 5 Patrick R. Gansterer 2013-08-02 11:53:11 PDT
(In reply to comment #4)
> (From update of attachment 207913 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207913&action=review
> 
> >>> Source/WebKit/win/WebURLResponse.cpp:375
> >>> +    String statusText = localizedShortDescriptionForStatusCode(statusCode);
> >> 
> >> Seems like this could be "const String& statusText" = ...; might allow return-value-optimization.
> > 
> > but then i need to change the whole function implementation, do you think it makes sense for this function? imho it's not called so often...
> 
> What? Why?  Does the BString constructor want a non-const String argument?

AFAIK WEB_UI_STRING returns String by value and not as a const reference (http://trac.webkit.org/browser/trunk/Source/WebCore/platform/LocalizedStrings.h?rev=152117#L263), so we must return String by value.
Maybe it's already too late for me today and I can't find my C++ knowledge about return values and object lifetime. :-)
BString is good with a const reference.
Comment 6 Brent Fulgham 2013-08-02 13:17:58 PDT
Comment on attachment 207913 [details]
Patch

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

>>>>> Source/WebKit/win/WebURLResponse.cpp:375
>>>>> +    String statusText = localizedShortDescriptionForStatusCode(statusCode);
>>>> 
>>>> Seems like this could be "const String& statusText" = ...; might allow return-value-optimization.
>>> 
>>> but then i need to change the whole function implementation, do you think it makes sense for this function? imho it's not called so often...
>> 
>> What? Why?  Does the BString constructor want a non-const String argument?
> 
> AFAIK WEB_UI_STRING returns String by value and not as a const reference (http://trac.webkit.org/browser/trunk/Source/WebCore/platform/LocalizedStrings.h?rev=152117#L263), so we must return String by value.
> Maybe it's already too late for me today and I can't find my C++ knowledge about return values and object lifetime. :-)
> BString is good with a const reference.

Right.  But under C++03 and newer, when you bind a temporary return value to a const reference, the compiler extends the lifetime of the return value to the lifetime of the const reference.  See http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/ for a brief overview.
Comment 7 Patrick R. Gansterer 2013-08-05 14:41:32 PDT
Created attachment 208149 [details]
Patch
Comment 8 Patrick R. Gansterer 2013-08-05 14:48:26 PDT
(In reply to comment #6)
> (From update of attachment 207913 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207913&action=review
> 
> >>>>> Source/WebKit/win/WebURLResponse.cpp:375
> >>>>> +    String statusText = localizedShortDescriptionForStatusCode(statusCode);
> >>>> 
> >>>> Seems like this could be "const String& statusText" = ...; might allow return-value-optimization.
> >>> 
> >>> but then i need to change the whole function implementation, do you think it makes sense for this function? imho it's not called so often...
> >> 
> >> What? Why?  Does the BString constructor want a non-const String argument?
> > 
> > AFAIK WEB_UI_STRING returns String by value and not as a const reference (http://trac.webkit.org/browser/trunk/Source/WebCore/platform/LocalizedStrings.h?rev=152117#L263), so we must return String by value.
> > Maybe it's already too late for me today and I can't find my C++ knowledge about return values and object lifetime. :-)
> > BString is good with a const reference.
> 
> Right.  But under C++03 and newer, when you bind a temporary return value to a const reference, the compiler extends the lifetime of the return value to the lifetime of the const reference.  See http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/ for a brief overview.

Sorry, I though about changing the return value to const ref... My fault!
Comment 9 WebKit Commit Bot 2013-08-07 00:18:38 PDT
Comment on attachment 208149 [details]
Patch

Clearing flags on attachment: 208149

Committed r153779: <http://trac.webkit.org/changeset/153779>
Comment 10 WebKit Commit Bot 2013-08-07 00:18:39 PDT
All reviewed patches have been landed.  Closing bug.