On Tue, Oct 7, 2014 at 12:25 PM, Dmitry Soshnikov <
dmitry.soshni...@gmail.com> wrote:

> On Tue, Oct 7, 2014 at 12:22 PM, Rick Waldron <waldron.r...@gmail.com>
> wrote:
>
>
>>
>> On Tue, Oct 7, 2014 at 3:01 PM, Dmitry Soshnikov <
>> dmitry.soshni...@gmail.com> wrote:
>>
>>> On Tue, Oct 7, 2014 at 11:59 AM, Dmitry Soshnikov <
>>> dmitry.soshni...@gmail.com> wrote:
>>>
>>>> On Tue, Oct 7, 2014 at 11:56 AM, Claude Pache <claude.pa...@gmail.com>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>>
>>>>> > Le 7 oct. 2014 à 20:36, Dmitry Soshnikov <dmitry.soshni...@gmail.com>
>>>>> a écrit :
>>>>> >
>>>>> > And other things are better be written:
>>>>> >
>>>>> > ```
>>>>> > <ArrayKind>.from(iterable).map(mapfn)
>>>>> > ```
>>>>> >
>>>>> > Am I still missing something?
>>>>>
>>>>> Yes:  `UInt32Array.from(['a', 'b', 'c], x => x.codePointAt(0))`
>>>>>
>>>>>
>>>> Still seems the same as `NodeList` "issue":
>>>>
>>>> ```
>>>> UInt32Array.from(['a', 'b', 'c].map(x => x.codePointAt(0)));
>>>> ```
>>>>
>>>
>>> And after you have fed the data the `UInt32Array` expects, you can
>>> post-map it as well:
>>>
>>>
>>> ```
>>> UInt32Array.from(['a', 'b', 'c].map(x => x.codePointAt(0))).map(v => v *
>>> 2);
>>> ```
>>>
>>> What's is wrong in here?
>>>
>>
>> That example will allocate 2 additional objects; the following version of
>> the same operation will allocate _zero_ additional objects:
>>
>>   UInt32Array.from(['a', 'b', 'c], x => x.codePointAt(0) * 2);
>>
>>
> Exactly. And this is what I mentioned at the beginning: the performance
> reasons shouldn't (never) overweight in "good API design" topics.
>
>
Since the next question will be: where is filter? It allows not allocating
stuff at all. However, we won't mention whether it's an anti-pattern or
not, since it goes without saying.

Dmitry
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to