mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 18:33:41 +00:00
8276904: Optional.toString() is unnecessarily expensive
Reviewed-by: rriggs, smarks
This commit is contained in:
parent
6e7b7f352e
commit
fe2ae8e38b
@ -454,7 +454,7 @@ public final class Optional<T> {
|
||||
@Override
|
||||
public String toString() {
|
||||
return value != null
|
||||
? String.format("Optional[%s]", value)
|
||||
? ("Optional[" + value + "]")
|
||||
: "Optional.empty";
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ public final class OptionalDouble {
|
||||
@Override
|
||||
public String toString() {
|
||||
return isPresent
|
||||
? String.format("OptionalDouble[%s]", value)
|
||||
? ("OptionalDouble[" + value + "]")
|
||||
: "OptionalDouble.empty";
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ public final class OptionalInt {
|
||||
@Override
|
||||
public String toString() {
|
||||
return isPresent
|
||||
? String.format("OptionalInt[%s]", value)
|
||||
? ("OptionalInt[" + value + "]")
|
||||
: "OptionalInt.empty";
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ public final class OptionalLong {
|
||||
@Override
|
||||
public String toString() {
|
||||
return isPresent
|
||||
? String.format("OptionalLong[%s]", value)
|
||||
? ("OptionalLong[" + value + "]")
|
||||
: "OptionalLong.empty";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user