int i = start;
while (i < end) {
boolean pixel = row.get(i);
- if ((!pixel && isWhite) || (pixel && !isWhite)) {
+ if (pixel ^ isWhite) { // that is, exactly one is true
counters[counterPosition]++;
} else {
counterPosition++;
break;
} else {
counters[counterPosition] = 1;
- isWhite = !isWhite;
+ isWhite ^= true; // isWhite = !isWhite; Is this too clever? shorter byte code, no conditional
}
}
i++;