Bug 210610 - Clean up VectorCocoa createNSArray overloads and add documentation for createNSArray taking a map function
Summary: Clean up VectorCocoa createNSArray overloads and add documentation for create...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-16 10:13 PDT by Daniel Bates
Modified: 2020-04-16 11:31 PDT (History)
6 users (show)

See Also:


Attachments
Patch (3.48 KB, patch)
2020-04-16 10:17 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (3.48 KB, patch)
2020-04-16 10:18 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (4.09 KB, patch)
2020-04-16 10:25 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (4.42 KB, patch)
2020-04-16 10:36 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
To Land (3.96 KB, patch)
2020-04-16 11:28 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2020-04-16 10:13:10 PDT
Clean up VectorCocoa createNSArray overloads and add documentation for createNSArray taking a map function.
Comment 1 Daniel Bates 2020-04-16 10:17:43 PDT
Created attachment 396661 [details]
Patch
Comment 2 Daniel Bates 2020-04-16 10:18:41 PDT
Created attachment 396662 [details]
Patch
Comment 3 Daniel Bates 2020-04-16 10:25:30 PDT
Created attachment 396665 [details]
Patch
Comment 4 Daniel Bates 2020-04-16 10:32:00 PDT
Comment on attachment 396665 [details]
Patch

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

> Source/WTF/ChangeLog:8
> +        Remove unncessary local variable. Rename "map" type in createNSArray function for clarity

unncessary => unnecessary
Comment 5 Daniel Bates 2020-04-16 10:32:00 PDT
Comment on attachment 396665 [details]
Patch

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

> Source/WTF/ChangeLog:8
> +        Remove unncessary local variable. Rename "map" type in createNSArray function for clarity

unncessary => unnecessary
Comment 6 Daniel Bates 2020-04-16 10:36:08 PDT
Created attachment 396667 [details]
Patch
Comment 7 Darin Adler 2020-04-16 11:07:47 PDT
Comment on attachment 396667 [details]
Patch

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

> Source/WTF/wtf/cocoa/VectorCocoa.h:56
> +// An overload that takes a map function and returns a NSArray whose elements are the
> +// result of calling the map function on each vector element. Like the makeNSArrayElement
> +// function, the map function can return either a RetainPtr<id> or an id if the value
> +// is autoreleased. When the map function is makeNSArrayElement then this function
> +// behaves identically to createNSArray function that does not take a map function.

I’m not thrilled with this comment. Here’s my cut:

    // This overload of createNSArray takes a function to map each vector element to an Objective-C object.
    // The map function has the same interface as the makeVectorElement function above, but can be any
    // function including a lambda, a function-like object, or Function<>.

I’m sure you can do even better.

> Source/WTF/wtf/cocoa/VectorCocoa.h:83
> -        constexpr const VectorElementType* typedNull = nullptr;
> +        constexpr VectorElementType* typedNull = nullptr;

Please don’t make this change. The const there is about the type of the pointed-to item. This const should not be removed. In some coding styles it would be written as "constexpr VectorElementType const *", in case that makes it clearer to you. If this was not a pointer type, then the change would make sense to me, removing a redundant const, but that’s based on a misunderstanding here.
Comment 8 Daniel Bates 2020-04-16 11:17:46 PDT
Comment on attachment 396667 [details]
Patch

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

>> Source/WTF/wtf/cocoa/VectorCocoa.h:56
>> +// behaves identically to createNSArray function that does not take a map function.
> 
> I’m not thrilled with this comment. Here’s my cut:
> 
>     // This overload of createNSArray takes a function to map each vector element to an Objective-C object.
>     // The map function has the same interface as the makeVectorElement function above, but can be any
>     // function including a lambda, a function-like object, or Function<>.
> 
> I’m sure you can do even better.

You're tempting me...I'll just take your cut.

>> Source/WTF/wtf/cocoa/VectorCocoa.h:83
>> +        constexpr VectorElementType* typedNull = nullptr;
> 
> Please don’t make this change. The const there is about the type of the pointed-to item. This const should not be removed. In some coding styles it would be written as "constexpr VectorElementType const *", in case that makes it clearer to you. If this was not a pointer type, then the change would make sense to me, removing a redundant const, but that’s based on a misunderstanding here.

You're right, I'm wrong. I misread the code.
Comment 9 Daniel Bates 2020-04-16 11:18:10 PDT
Thanks for the review, btw
Comment 10 Daniel Bates 2020-04-16 11:26:31 PDT
Comment on attachment 396667 [details]
Patch

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

>>> Source/WTF/wtf/cocoa/VectorCocoa.h:56
>>> +// behaves identically to createNSArray function that does not take a map function.
>> 
>> I’m not thrilled with this comment. Here’s my cut:
>> 
>>     // This overload of createNSArray takes a function to map each vector element to an Objective-C object.
>>     // The map function has the same interface as the makeVectorElement function above, but can be any
>>     // function including a lambda, a function-like object, or Function<>.
>> 
>> I’m sure you can do even better.
> 
> You're tempting me...I'll just take your cut.

The same interface as makeVectorElement? The same interface as makeNSArrayElement
Comment 11 Daniel Bates 2020-04-16 11:28:51 PDT
Created attachment 396675 [details]
To Land
Comment 12 Daniel Bates 2020-04-16 11:30:34 PDT
Comment on attachment 396675 [details]
To Land

Clearing flags on attachment: 396675

Committed r260202: <https://trac.webkit.org/changeset/260202>
Comment 13 Daniel Bates 2020-04-16 11:30:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Radar WebKit Bug Importer 2020-04-16 11:31:16 PDT
<rdar://problem/61895756>