RESOLVED FIXED 75586
WebFrameLoaderClient::userAgent does unnecessary NSString/NSURL conversions
https://bugs.webkit.org/show_bug.cgi?id=75586
Summary WebFrameLoaderClient::userAgent does unnecessary NSString/NSURL conversions
Pratik Solanki
Reported 2012-01-04 15:57:04 PST
WebFrameLoaderClient::userAgent calls -(NSString *)userAgentForURL:(NSURL *)url on WebView to get the user agent string. This results in - converting KURL to NSURL* before passing to userAgentForURL (note that the function does't use the argument at all!) - Since userAgentForURL returns an NSString* but stores the user agent internally as WTF::String, it converts the String to NSString* before returning - WebFrameLoaderClient::userAgent converts that NSString back into a WTF::String when returning We can optimize this by having a separate code path that takes a KURL and returns String.
Attachments
Patch (3.50 KB, patch)
2012-01-04 23:30 PST, Pratik Solanki
no flags
Patch (3.44 KB, patch)
2012-01-05 10:38 PST, Pratik Solanki
ap: review+
Pratik Solanki
Comment 1 2012-01-04 15:57:58 PST
Pratik Solanki
Comment 2 2012-01-04 23:30:51 PST
Alexey Proskuryakov
Comment 3 2012-01-05 10:24:45 PST
Comment on attachment 121222 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=121222&action=review It seems that the knowledge of obsolete url argument can be isolated in API method - no need to add a new new that's still going to ignore its argument. Dead code for "No current site-specific spoofs" can go away, too. > Source/WebKit/mac/WebView/WebView.mm:3892 > + return [self _userAgentStringForURL:(KURL*)url]; Even though the argument is unused in practice, casting to an unrelated type is a bug.
Pratik Solanki
Comment 4 2012-01-05 10:33:16 PST
(In reply to comment #3) > (From update of attachment 121222 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=121222&action=review > > It seems that the knowledge of obsolete url argument can be isolated in API method - no need to add a new new that's still going to ignore its argument. Dead code for "No current site-specific spoofs" can go away, too. > Ok. > > Source/WebKit/mac/WebView/WebView.mm:3892 > > + return [self _userAgentStringForURL:(KURL*)url]; > > Even though the argument is unused in practice, casting to an unrelated type is a bug. Yeah, I was debating on this cast as well. I'll just remove it given that the new function shouldn't take a URL argument.
Pratik Solanki
Comment 5 2012-01-05 10:38:40 PST
Pratik Solanki
Comment 6 2012-01-05 11:03:44 PST
Note You need to log in before you can comment on or make changes to this bug.