Re: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-27 Thread Peter Levart
Hi Mike, Yes, all that you say below is true. CharSequence is an interface that does not define the contract of identity when implementations/subtypes of CharSequence do - each in it's own way. Much like java.util.Collection and List vs. Set. It's always dangerous for methods that return such

Re: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-26 Thread Martin Desruisseaux
If String.substring(int, int) now performs a copy of the underlying char[] array and if there is no String.subSequence(int, int) providing the old functionality, maybe the following implications should be investigated? StringBuilder.append(...) Since, in order to avoid a

Re: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-26 Thread Mike Duigou
On Jun 26 2012, at 07:13 , Martin Desruisseaux wrote: If String.substring(int, int) now performs a copy of the underlying char[] array and if there is no String.subSequence(int, int) providing the old functionality, maybe the following implications should be investigated?

Re: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-26 Thread Martin Desruisseaux
Le 26/06/12 20:10, Mike Duigou a écrit : StringBuilder.append(string.substring(lower, upper)); by: StringBuilder.append(string, lower, upper); This would seem to be a good refactoring regardless of the substring implementation as it avoids creation of a temporary object. The

Re: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-25 Thread Alan Bateman
On 22/06/2012 23:15, Mike Duigou wrote: : - The CharSequences returned by subSequence would follow only the general CharSequence rules for equals()/hashCode(). Any current usages of the result of subSequence for equals() or hashing, even though it's not advised, would break. We could add

RE: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-24 Thread Jason Mehrens
Mike, Why not implement subSequence as 'java.nio.CharBuffer.wrap(data, beginIndex, endIndex).asReadOnlyBuffer()' ? Easy to implement and test. The nice thing is that parsers would know what a 'CharBuffer' vs. a sub sequence String internal class. Jason Subject: String.subSequence and

Re: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String

2012-06-24 Thread Mike Duigou
As usual, an excellent idea Jason. I'll probably run an internal test/benchmark with both this and the CharSequence inner class implementation to see what breaks and where there are performance differences between the two. I was planning to also test a version of the CharSequence implementation