Request for Review : CR#6924259: Remove String.count/String.offset

Rémi Forax forax at univ-mlv.fr
Fri May 25 22:33:21 UTC 2012


On 05/26/2012 12:09 AM, Mike Duigou wrote:
> On May 25 2012, at 06:57 , Rémi Forax wrote:
>
>> Hi Mike, Hi Alan, Hi all,
>> in my opinion, EMPTY_STRING_VALUE is a premature optimization,
>> the idea is, I think, to avoid to create an empty char but if you want to do that,
>> it's better to do that in StringBuilder.toString() to avoid to create the String at all.
> I have removed most of the use of EMPTY_STRING_VALUE. It remains for the empty constructor only.

I may be wrong but this constructor is used rarely
so for me it's like you add one static field that will be never used.

[...]

>
>> Recently, _getChars(char[], int) was replaced by
>> getChars(char[],int). It was a stupid change because now
>> one can think that getChar(char[], int) and getChar(int,int,char[],int)
>> do the same things. but getChat(char[],int) don't do any bounds check.
>> So concat() and toCharArray() doesn't do any bound check !
> I don't see where either of them need to do any checking.

duh, sorry, I've forgotten the basics. You're right.

>
>> toCharArray() should use Arrays.copyOf()
> Done.
>
>> Overloads of encode in StringCoding are in my opinion not necessary
>> because each method is called once.
> Reasonable. I opted not to add the 3rd variant ([] count) because it wasn't used. I've reverted to using the 3 param version.
>
>> So this doesn't really share code
>> but just add one level to the depth of the call stack.
>>
>> cheers,
>> Rémi

regards,
Rémi




More information about the core-libs-dev mailing list