Please review: surrogate fiddle
Alexander Zuev
alexander.zuev at oracle.com
Wed Mar 20 15:00:53 UTC 2013
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
More information about the core-libs-dev
mailing list