mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
6924259: Remove offset and count fields from java.lang.String
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
This commit is contained in:
parent
4747e218b3
commit
f55750d05a
4 changed files with 237 additions and 291 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue