mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-26 10:10:19 +00:00
Rename to encodedLength
This commit is contained in:
parent
e04a5c1ae8
commit
f9505f60c3
@ -2116,7 +2116,7 @@ public final class String
|
||||
* @param cs The {@link Charset} used to the compute the length
|
||||
* @since 27
|
||||
*/
|
||||
public int getEncodedLength(Charset cs) {
|
||||
public int encodedLength(Charset cs) {
|
||||
Objects.requireNonNull(cs);
|
||||
if (cs == UTF_8.INSTANCE) {
|
||||
return encodedLengthUTF8(coder, value);
|
||||
|
||||
@ -106,9 +106,9 @@ public class Encodings {
|
||||
if (!equals(bs, bytes))
|
||||
throw new Exception(charset + ": String.getBytes failed");
|
||||
|
||||
/* String.getEncodedLength(Charset charset) */
|
||||
if (bs.length != str.getEncodedLength(charset))
|
||||
throw new Exception(charset + ": String.getEncodedLength failed");
|
||||
/* String.encodedLength(Charset charset) */
|
||||
if (bs.length != str.encodedLength(charset))
|
||||
throw new Exception(charset + ": String.encodedLength failed");
|
||||
|
||||
// Calls to String.getBytes(Charset) shouldn't automatically
|
||||
// use the cached thread-local encoder.
|
||||
|
||||
@ -397,11 +397,11 @@ public class Exceptions {
|
||||
}});
|
||||
}
|
||||
|
||||
private static void getEncodedLength() {
|
||||
System.out.println("getEncodedLength(Charset charset)");
|
||||
private static void encodedLength() {
|
||||
System.out.println("encodedLength(Charset charset)");
|
||||
tryCatch(" null", NullPointerException.class, new Runnable() {
|
||||
public void run() {
|
||||
"foo".getEncodedLength((Charset)null);
|
||||
"foo".encodedLength((Charset)null);
|
||||
}});
|
||||
}
|
||||
|
||||
@ -648,7 +648,7 @@ public class Exceptions {
|
||||
// getBytes(Locale)
|
||||
// getBytes(String)
|
||||
// getBytes(Charset)
|
||||
getEncodedLength(); // getEncodedLength(Charset)
|
||||
encodedLength(); // encodedLength(Charset)
|
||||
contentEquals(); // contentEquals(StringBuffer)
|
||||
compareTo(); // compareTo(String), compareTo(Object)
|
||||
compareToIgnoreCase();// compareToIgnoreCase(String)
|
||||
|
||||
@ -169,11 +169,11 @@ public class TestStringCoding {
|
||||
if (!Arrays.equals(baSC, baNIO)) {
|
||||
throw new RuntimeException("getBytes(cs) failed -> " + cs.name());
|
||||
}
|
||||
//getEncodedLength(cs);
|
||||
int getEncodedLength = str.getEncodedLength(cs);
|
||||
if (baSC.length != getEncodedLength) {
|
||||
throw new RuntimeException(String.format("getEncodedLength failed (%d != %d) -> %s",
|
||||
baSC.length, getEncodedLength, cs.name()));
|
||||
//encodedLength(cs);
|
||||
int encodedLength = str.encodedLength(cs);
|
||||
if (baSC.length != encodedLength) {
|
||||
throw new RuntimeException(String.format("encodedLength failed (%d != %d) -> %s",
|
||||
baSC.length, encodedLength, cs.name()));
|
||||
}
|
||||
return baSC;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class StringLoopJmhBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public int getEncodedLength() throws Exception {
|
||||
return stringData.getEncodedLength(StandardCharsets.UTF_8);
|
||||
public int encodedLength() throws Exception {
|
||||
return stringData.encodedLength(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user