Re: String.substring when beginIndex is the string's length

2015-02-18 Thread Zoltan Sziladi
v/c60cf8acabb2 > > Going further and removing the String allocation entirely (returning "") > might have unexpected side-effects for some code expecting a new, distinct > object. Any potential benefit might also be eaten up by increased byte > code, > more branches etc.

String.substring when beginIndex is the string's length

2015-02-18 Thread Zoltan Sziladi
Hi, There are 2 things I do not understand about how substring works, hopefully someone can shed some light on it. 1. When you call substring and you provide the string's length as beginIndex, why does it return an empty string instead of throwing an exception? You are effectively indexing outsid

Re: String.indexOf optimization

2015-01-26 Thread Zoltan Sziladi
Hi Martin, Nice catches on the cleanup! By the way, can you tell me why you used named loops in your code? Isn't it considered bad practice as it is almost like a goto statement? Couldn't we refactor it in a way that we do not use named loops? Also, if there is a for loop that has no start state

Re: String.indexOf optimization

2015-01-19 Thread Zoltan Sziladi
rgetCount, > int fromIndex) { > > It does look like we can tighten the code up a little... > > > On Thu, Jan 8, 2015 at 3:05 PM, Zoltan Sziladi > wrote: > >> Thanks for the info. >> So that basically means we have 2 implementations of indexOf curren

Re: String.indexOf optimization

2015-01-08 Thread Zoltan Sziladi
function, or (c) some other JVM > that doesn't intrinsify this method (or any method). > > People don't usually disable intrinsics; if they do, it's because they hit > some JIT bug and may disable it. > > On Thu, Jan 8, 2015 at 3:34 PM, Zoltan Sziladi > wrote: >

Re: String.indexOf optimization

2015-01-08 Thread Zoltan Sziladi
he indexOf function not intrinsified? When do people usually disable intrinsification? Sorry if these are newbie questions, I'm new to this part of Java. Regards, Zoltan On Tue, Jan 6, 2015 at 1:28 AM, Andrew Haley wrote: > Hi, > > On 05/01/15 18:59, Zoltan Sziladi wrote: > >

Re: String.indexOf optimization

2015-01-05 Thread Zoltan Sziladi
Hi, This discussion was a long time ago, I was just reading through it to check again what was the last state of the discussion about the String.indexOf. There is one part which I still do not understand, hopefully someone could shed some light on it. A few emails ago Martin mentioned "Hotspot se

Re: String.indexOf optimization

2014-04-07 Thread Zoltan Sziladi
to implement efficiently. > > > On Fri, Apr 4, 2014 at 7:49 AM, Zoltan Sziladi wrote: >> >> Hi, >> >> I am new to this mailing list so please forgive me if this has been >> discussed before. >> >> I was looking at the implementation of String.inde

String.indexOf optimization

2014-04-04 Thread Zoltan Sziladi
Hi, I am new to this mailing list so please forgive me if this has been discussed before. I was looking at the implementation of String.indexOf and I see that it uses the O(n^2) naive implementation. I have been trying to find out why it does not use some kind of a modern, sophisticated O(n) algo