Re: [ALL] Performance of foreach loop with arrays.

2016-05-19 Thread Benedikt Ritter
sebb schrieb am Mo., 16. Mai 2016 um 15:14 Uhr: > Looking for feedback on C-style and foreach() loops when using arrays. > [This email does not consider collections; please start another thread > if you want to discuss that.] > > TLDR; Always use foreach() with arrays unless you need access to th

Re: [ALL] Performance of foreach loop with arrays.

2016-05-17 Thread sebb
On 17 May 2016 at 06:04, Eric Barnhill wrote: > I have a related story. There is a class in commons-math 4.0 called > IntegerRange. Stylistically I much prefer Iterating over such a range than > C style loops and was ready to convert. However I found it many times > slower, at least in not terribl

Re: [ALL] Performance of foreach loop with arrays.

2016-05-17 Thread Eric Barnhill
Sorry one further comment. While I like iterators stylistically, in the design process I have generally chosen to stick with C style loops. This is because, often later in the design process, I decide I want access to the index after all for some reason, and at point it is easier to call the inde

Re: [ALL] Performance of foreach loop with arrays.

2016-05-16 Thread Eric Barnhill
I have a related story. There is a class in commons-math 4.0 called IntegerRange. Stylistically I much prefer Iterating over such a range than C style loops and was ready to convert. However I found it many times slower, at least in not terribly rigorous home micro-benchmarking. Any good reason wh

Re: [ALL] Performance of foreach loop with arrays.

2016-05-16 Thread Stian Soiland-Reyes
On 16 May 2016 at 14:13, sebb wrote: > Looking for feedback on C-style and foreach() loops when using arrays. > [This email does not consider collections; please start another thread > if you want to discuss that.] > > TLDR; Always use foreach() with arrays unless you need access to the index. +1

[ALL] Performance of foreach loop with arrays.

2016-05-16 Thread sebb
Looking for feedback on C-style and foreach() loops when using arrays. [This email does not consider collections; please start another thread if you want to discuss that.] TLDR; Always use foreach() with arrays unless you need access to the index. == There are two main ways to iterate over an ar