I guess it depends.
Obtaining the array is not free: it needs to be allocated, then initialized
with zeros (Java lang spec), and finally the String contents are copied into
it.
Once we have an array, accessing its elements directly will be faster than
going through the String wrapper object si
But shouldn't the comparison really be using [] access as opposed to
charAt()?
Gary
On Nov 25, 2016 6:41 PM, "Remko Popma" wrote:
> No this is actually faster.
> I believe I created a benchmark for this that showed that for-each
> iteration is slower than indexed iteration.
>
> Sent from my iPh
No this is actually faster.
I believe I created a benchmark for this that showed that for-each iteration is
slower than indexed iteration.
Sent from my iPhone
> On 26 Nov 2016, at 11:29, Gary Gregory wrote:
>
> Isn't this code slower? It feels like we are putting memory performance ahead
>