<Sound Dev> [11] Review Request: 8205456 Unification of iterations over arrays

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

<Sound Dev> [11] Review Request: 8205456 Unification of iterations over arrays

Sergey Bylokhov
Hello, Audio Guru.

Please review the small cleanup for jdk11.

Bug: https://bugs.openjdk.java.net/browse/JDK-8205456
Webrev: http://cr.openjdk.java.net/~serb/8205456/webrev.00

Currently we have a few patters to work with arrays in JavaSound.
  - Iterates using the for loop
  - Iterates using Arrays.asList
  - Iterates using Stream.of

  - I suggest to unify this and use Arrays.stream in all cases, because
it works for arrays of objects and primitives(I have skip
AudioSystem/MidiSystem in this fix, I will update them some time later)
  - In a few places I also changed manual iteration over array to ".clone()"
  - small cleanup is done(empty lines/unused vars/etc are removed)

--
Best regards, Sergey.
Reply | Threaded
Open this post in threaded view
|

Re: <Sound Dev> [11] Review Request: 8205456 Unification of iterations over arrays

Dan Rollo
Hi Sergey, 

Nifty. 
The “Arrays.stream” approach handles the case where the passed in parameter is null? Assuming, yes, then looks good to me.

Dan

On Jun 20, 2018, at 10:27 PM, Sergey Bylokhov <[hidden email]> wrote:

Hello, Audio Guru.

Please review the small cleanup for jdk11.

Bug: https://bugs.openjdk.java.net/browse/JDK-8205456
Webrev: http://cr.openjdk.java.net/~serb/8205456/webrev.00

Currently we have a few patters to work with arrays in JavaSound.
- Iterates using the for loop
- Iterates using Arrays.asList
- Iterates using Stream.of

- I suggest to unify this and use Arrays.stream in all cases, because it works for arrays of objects and primitives(I have skip AudioSystem/MidiSystem in this fix, I will update them some time later)
- In a few places I also changed manual iteration over array to ".clone()"
- small cleanup is done(empty lines/unused vars/etc are removed)

--
Best regards, Sergey.

Reply | Threaded
Open this post in threaded view
|

Re: <Sound Dev> [11] Review Request: 8205456 Unification of iterations over arrays

Philip Race
Assuming Dan gets a satisfactory answer, this is OK by me.

-phil.

On 06/21/2018 02:44 PM, Dan Rollo wrote:
Hi Sergey, 

Nifty. 
The “Arrays.stream” approach handles the case where the passed in parameter is null? Assuming, yes, then looks good to me.

Dan

On Jun 20, 2018, at 10:27 PM, Sergey Bylokhov <[hidden email]> wrote:

Hello, Audio Guru.

Please review the small cleanup for jdk11.

Bug: https://bugs.openjdk.java.net/browse/JDK-8205456
Webrev: http://cr.openjdk.java.net/~serb/8205456/webrev.00

Currently we have a few patters to work with arrays in JavaSound.
- Iterates using the for loop
- Iterates using Arrays.asList
- Iterates using Stream.of

- I suggest to unify this and use Arrays.stream in all cases, because it works for arrays of objects and primitives(I have skip AudioSystem/MidiSystem in this fix, I will update them some time later)
- In a few places I also changed manual iteration over array to ".clone()"
- small cleanup is done(empty lines/unused vars/etc are removed)

--
Best regards, Sergey.


Reply | Threaded
Open this post in threaded view
|

Re: <Sound Dev> [11] Review Request: 8205456 Unification of iterations over arrays

Sergey Bylokhov
In reply to this post by Dan Rollo
Yes, unlike "Arrays.asList" which accepts null, the “Arrays.stream” will
throw NPE(so result is the same as before the fix)

On 21/06/2018 14:44, Dan Rollo wrote:

> Hi Sergey,
>
> Nifty.
> The “Arrays.stream” approach handles the case where the passed in
> parameter is null? Assuming, yes, then looks good to me.
>
> Dan
>
>> On Jun 20, 2018, at 10:27 PM, Sergey Bylokhov
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> Hello, Audio Guru.
>>
>> Please review the small cleanup for jdk11.
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8205456
>> Webrev: http://cr.openjdk.java.net/~serb/8205456/webrev.00
>>
>> Currently we have a few patters to work with arrays in JavaSound.
>> - Iterates using the for loop
>> - Iterates using Arrays.asList
>> - Iterates using Stream.of
>>
>> - I suggest to unify this and use Arrays.stream in all cases, because
>> it works for arrays of objects and primitives(I have skip
>> AudioSystem/MidiSystem in this fix, I will update them some time later)
>> - In a few places I also changed manual iteration over array to ".clone()"
>> - small cleanup is done(empty lines/unused vars/etc are removed)
>>
>> --
>> Best regards, Sergey.
>


--
Best regards, Sergey.
Reply | Threaded
Open this post in threaded view
|

Re: <Sound Dev> [11] Review Request: 8205456 Unification of iterations over arrays

Dan Rollo
+1

Dan

On Jun 21, 2018, at 7:54 PM, Sergey Bylokhov <[hidden email]> wrote:

Yes, unlike "Arrays.asList" which accepts null, the “Arrays.stream” will throw NPE(so result is the same as before the fix)

On 21/06/2018 14:44, Dan Rollo wrote:
Hi Sergey,
Nifty.
The “Arrays.stream” approach handles the case where the passed in parameter is null? Assuming, yes, then looks good to me.
Dan
On Jun 20, 2018, at 10:27 PM, Sergey Bylokhov <[hidden email]<[hidden email]>> wrote:

Hello, Audio Guru.

Please review the small cleanup for jdk11.

Bug: https://bugs.openjdk.java.net/browse/JDK-8205456
Webrev: http://cr.openjdk.java.net/~serb/8205456/webrev.00

Currently we have a few patters to work with arrays in JavaSound.
- Iterates using the for loop
- Iterates using Arrays.asList
- Iterates using Stream.of

- I suggest to unify this and use Arrays.stream in all cases, because it works for arrays of objects and primitives(I have skip AudioSystem/MidiSystem in this fix, I will update them some time later)
- In a few places I also changed manual iteration over array to ".clone()"
- small cleanup is done(empty lines/unused vars/etc are removed)

-- 
Best regards, Sergey.


-- 
Best regards, Sergey.