提交 938adb2d 编写于 作者: M mduigou

6924259: Remove offset and count fields from java.lang.String

Summary: Removes the use of shared character array buffers by String along with the two fields needed to support the use of shared buffers.
Reviewed-by: alanb, mduigou, forax, briangoetz
Contributed-by: brian.doherty@oracle.com
上级 3e2b261e
......@@ -381,7 +381,7 @@ public final class Integer extends Number implements Comparable<Integer> {
int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
char[] buf = new char[size];
getChars(i, size, buf);
return new String(0, size, buf);
return new String(buf, true);
}
/**
......
......@@ -373,7 +373,7 @@ public final class Long extends Number implements Comparable<Long> {
int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
char[] buf = new char[size];
getChars(i, size, buf);
return new String(0, size, buf);
return new String(buf, true);
}
/**
......
......@@ -250,6 +250,7 @@ class StringCoding {
static char[] decode(byte[] ba, int off, int len) {
String csn = Charset.defaultCharset().name();
try {
// use charset name decode() variant which provides caching.
return decode(csn, ba, off, len);
} catch (UnsupportedEncodingException x) {
warnUnsupportedCharset(csn);
......@@ -382,6 +383,7 @@ class StringCoding {
static byte[] encode(char[] ca, int off, int len) {
String csn = Charset.defaultCharset().name();
try {
// use charset name encode() variant which provides caching.
return encode(csn, ca, off, len);
} catch (UnsupportedEncodingException x) {
warnUnsupportedCharset(csn);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册