--- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java Wed Jun 30 16:11:31 2010 -0700
+++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java Wed Jun 30 16:11:32 2010 -0700
@@ -721,20 +721,19 @@
* {@code codePoint} isn't a valid Unicode code point
*/
public AbstractStringBuilder appendCodePoint(int codePoint) {
- if (!Character.isValidCodePoint(codePoint)) {
+ final int count = this.count;
+
+ if (Character.isBmpCodePoint(codePoint)) {
+ ensureCapacityInternal(count + 1);
+ value[count] = (char) codePoint;
+ this.count = count + 1;
+ } else if (Character.isValidCodePoint(codePoint)) {
+ ensureCapacityInternal(count + 2);
+ Character.toSurrogates(codePoint, value, count);
+ this.count = count + 2;
+ } else {
throw new IllegalArgumentException();
}
- int n = 1;
- if (codePoint >= Character.MIN_SUPPLEMENTARY_CODE_POINT) {
- n++;
- }
- ensureCapacityInternal(count + n);
- if (n == 1) {
- value[count++] = (char) codePoint;
- } else {
- Character.toSurrogates(codePoint, value, count);
- count += n;
- }
return this;
}