mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
c998ead188
commit
a3df1d618e
155 changed files with 340 additions and 382 deletions
|
@ -664,7 +664,7 @@ public final class String
|
|||
* object.
|
||||
*/
|
||||
public int length() {
|
||||
return value.length >> coder();
|
||||
return isLatin1() ? value.length : value.length >> UTF16;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1943,8 +1943,7 @@ public final class String
|
|||
* characters followed by the string argument's characters.
|
||||
*/
|
||||
public String concat(String str) {
|
||||
int olen = str.length();
|
||||
if (olen == 0) {
|
||||
if (str.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
if (coder() == str.coder()) {
|
||||
|
@ -1956,6 +1955,7 @@ public final class String
|
|||
return new String(buf, coder);
|
||||
}
|
||||
int len = length();
|
||||
int olen = str.length();
|
||||
byte[] buf = StringUTF16.newBytesFor(len + olen);
|
||||
getBytes(buf, 0, UTF16);
|
||||
str.getBytes(buf, len, UTF16);
|
||||
|
@ -2316,7 +2316,7 @@ public final class String
|
|||
// Construct result
|
||||
int resultSize = list.size();
|
||||
if (limit == 0) {
|
||||
while (resultSize > 0 && list.get(resultSize - 1).length() == 0) {
|
||||
while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) {
|
||||
resultSize--;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue