Please review: surrogate fiddle (original) (raw)
Alexander Zuev alexander.zuev at oracle.com
Wed Mar 20 15:00:53 UTC 2013
- Previous message: Please review: surrogate fiddle
- Next message: Please review: surrogate fiddle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Ulf,
please see my comments inline.
On 3/20/13 18:09, Ulf Zibis wrote:
Hi Martin,
nice to see you again on board. Am 19.03.2013 20:18, schrieb Martin Buchholz: Thanks! Webrev updated. Character: Maybe I'm blind, is there any semantical difference between char c1 = seq.charAt(index++); if (isHighSurrogate(c1)) { if (index < seq.length()) {_ _and_ _char c1 = seq.charAt(index);_ _if (isHighSurrogate(c1) && ++index < seq.length()) {_ _, or is it just for beautifying the code?_ The only real difference i see is that in case of isHighSurrogate(c1) == false we saving one increment instruction. May be a real deal for performance junkie :) _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.
Just my $.02
With best regards, Alex
- Previous message: Please review: surrogate fiddle
- Next message: Please review: surrogate fiddle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]