Bug 229414 - Cut down on use of CFGetTypeID, using dynamic_cf_cast instead; related streamlining
Summary: Cut down on use of CFGetTypeID, using dynamic_cf_cast instead; related stream...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks: 239591
  Show dependency treegraph
 
Reported: 2021-08-23 12:22 PDT by Darin Adler
Modified: 2022-05-12 11:17 PDT (History)
26 users (show)

See Also:


Attachments
Patch (99.85 KB, patch)
2021-08-23 13:35 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (100.14 KB, patch)
2021-08-23 14:00 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (102.17 KB, patch)
2021-08-26 10:43 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (103.30 KB, patch)
2021-08-26 12:35 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (103.39 KB, patch)
2021-08-26 18:42 PDT, Darin Adler
thorton: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2021-08-23 12:22:47 PDT
Cut down on use of CFGetTypeID, using dynamic_cf_cast instead; related streamlining
Comment 1 Darin Adler 2021-08-23 13:35:44 PDT
Created attachment 436230 [details]
Patch
Comment 2 Darin Adler 2021-08-23 14:00:13 PDT
Created attachment 436233 [details]
Patch
Comment 3 Myles C. Maxfield 2021-08-23 14:35:29 PDT
dynamic_cf_cast! Very cool!
Comment 4 Joseph Pecoraro 2021-08-23 14:55:06 PDT
Comment on attachment 436233 [details]
Patch

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

> Source/WebCore/platform/ios/UserAgentIOS.mm:-85
> -        String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName);

Is there a performance benefit to removing these intermediate variables? These `appNameSuffix` variables seemed to make the code more readable, but that may just be personal preference.
Comment 5 Darin Adler 2021-08-23 15:02:20 PDT
Comment on attachment 436233 [details]
Patch

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

>> Source/WebCore/platform/ios/UserAgentIOS.mm:-85
>> -        String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName);
> 
> Is there a performance benefit to removing these intermediate variables? These `appNameSuffix` variables seemed to make the code more readable, but that may just be personal preference.

Yes, there is a performance benefit.

But I can do a different version where we still have local variables, just different ones, and still keep the performance benefit. For example, you might like this better:

    auto separator = applicationName.isEmpty() ? "" : " ";
    return makeString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko)", separator, applicationName);
Comment 6 Joseph Pecoraro 2021-08-23 15:37:05 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 436233 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=436233&action=review
> 
> >> Source/WebCore/platform/ios/UserAgentIOS.mm:-85
> >> -        String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName);
> > 
> > Is there a performance benefit to removing these intermediate variables? These `appNameSuffix` variables seemed to make the code more readable, but that may just be personal preference.
> 
> Yes, there is a performance benefit.
> 
> But I can do a different version where we still have local variables, just
> different ones, and still keep the performance benefit. For example, you
> might like this better:
> 
>     auto separator = applicationName.isEmpty() ? "" : " ";
>     return makeString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6)
> AppleWebKit/605.1.15 (KHTML, like Gecko)", separator, applicationName);

Yeah that reads better to me then the inlined ternary, just having the name "separator" or "suffix" is helpful to understand the intent.
Comment 7 Darin Adler 2021-08-24 08:59:30 PDT
Comment on attachment 436233 [details]
Patch

Looks like this broke iOS, should be easy to fix. But also, not compiling on Windows, trivial to fix. So not ready to review yet.
Comment 8 Darin Adler 2021-08-26 10:43:36 PDT Comment hidden (obsolete)
Comment 9 Darin Adler 2021-08-26 12:35:46 PDT Comment hidden (obsolete)
Comment 10 Darin Adler 2021-08-26 18:42:29 PDT
Created attachment 436600 [details]
Patch
Comment 11 Darin Adler 2021-08-27 09:38:46 PDT
Looks like it is passing all EWS tests now, so ready for a review.

I improved the coding style at Joe’s request to use a local variable.
Comment 12 Radar WebKit Bug Importer 2021-08-30 12:23:23 PDT
<rdar://problem/82540876>
Comment 13 Tim Horton 2021-08-30 18:59:01 PDT
Comment on attachment 436600 [details]
Patch

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

> Source/WebKitLegacy/cf/ChangeLog:9
> +        (loadSetting): Rename from populateSetting. Use dyanmic_cf_cast, kCFBooleanTrue, and

`dyanmic`
Comment 14 Darin Adler 2021-08-30 20:43:41 PDT
Committed r281791 (241128@main): <https://commits.webkit.org/241128@main>
Comment 15 Darin Adler 2021-08-30 20:49:32 PDT
Comment on attachment 436600 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        (WebCore::makeSimpleColorFromARGBCFArray): Use dyanamic_cf_cast.

Fixed this one.

>> Source/WebKitLegacy/cf/ChangeLog:9
>> +        (loadSetting): Rename from populateSetting. Use dyanmic_cf_cast, kCFBooleanTrue, and
> 
> `dyanmic`

Didn’t fix this one, because I thought your comment was about the other one!
Comment 16 Eric Carlson 2022-05-12 11:17:05 PDT
Comment on attachment 436600 [details]
Patch

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

> Source/WTF/wtf/cf/TypeCastsCF.h:2
> + * Copyright (C) 2014-2021 Apple Inc. All rights reserved.

Did you mean to update to only 2021?

> Source/WebCore/platform/network/mac/WebCoreURLResponse.h:2
> + * Copyright (C) 2008-2021 Apple Inc. All rights reserved.

Ditto

> Source/WebCore/platform/network/mac/WebCoreURLResponse.mm:2
> + * Copyright (C) 2008-2021 Apple Inc. All rights reserved.

Ditto

> Source/WebKitLegacy/cf/WebCoreSupport/WebInspectorClientCF.cpp:2
> + * Copyright (C) 2008-2021 Apple Inc. All Rights Reserved.

Ditto.