Please review: surrogate fiddle (original) (raw)
Ulf Zibis Ulf.Zibis at CoSoCo.de
Thu Mar 21 13:09:10 UTC 2013
- Previous message: Please review: surrogate fiddle
- Next message: Please review: surrogate fiddle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Please review: surrogate fiddle
- Next message: Please review: surrogate fiddle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]