8215281: Use String.isEmpty() when applicable in java.base

Reviewed-by: dfuchs, alanb
This commit is contained in:
Claes Redestad 2018-12-13 15:31:05 +01:00
parent c998ead188
commit a3df1d618e
155 changed files with 340 additions and 382 deletions

View file

@ -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--;
}
}