Please review: surrogate fiddle
Ulf Zibis
Ulf.Zibis at CoSoCo.de
Thu Mar 21 13:09:10 UTC 2013
Am 20.03.2013 16:00, schrieb Alexander Zuev:
>> AbstractStringBuilder:
>> Instead
>> 270 public int codePointBefore(int index) {
>> 271 int i = index - 1;
>> 272 if ((i < 0) || (i >= count)) {
>> 273 throw new StringIndexOutOfBoundsException(index);
>> 274 }
>> I suggest
>> 270 public int codePointBefore(int index) {
>> 271 if ((--index < 0) || (index >= count)) {
>> 272 throw new StringIndexOutOfBoundsException(index);
>> 273 }
>> , because if e.g. the initial value of index is 0, then -1 reflects the out-of-bound condition,
>> but not the initial 0 to report in the StringIndexOutOfBoundsException.
> OTOH in case of upper index out of bounds with your code we will report exception reporting number
> laying within the allowed range which may be confusing.
Yes, difficult to decide, but keep in the back of your mind, it's called
_String_IndexOutOfBoundsException, not _CodepointAt_IndexOutOfBoundsException
> Just my $.02
adding my -,02 €
-Ulf
More information about the core-libs-dev
mailing list