Date: Fri, 9 Jun 2023 11:15:09 +0800
Subject:  8276904: Optional.toString() is unnecessarily expensive

Bug url: https://bugs.openjdk.org/browse/JDK-8276904
---
 jdk/src/share/classes/java/util/Optional.java       | 2 +-
 jdk/src/share/classes/java/util/OptionalDouble.java | 2 +-
 jdk/src/share/classes/java/util/OptionalInt.java    | 2 +-
 jdk/src/share/classes/java/util/OptionalLong.java   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/jdk/src/share/classes/java/util/Optional.java b/jdk/src/share/classes/java/util/Optional.java
index d471058ec..ff2b4db7f 100644
--- a/jdk/src/share/classes/java/util/Optional.java
+++ b/jdk/src/share/classes/java/util/Optional.java
@@ -343,7 +343,7 @@ public final class Optional<T> {
     @Override
     public String toString() {
         return value != null
-            ? String.format("Optional[%s]", value)
+            ? ("Optional[" + value + "]")
             : "Optional.empty";
     }
 }
diff --git a/jdk/src/share/classes/java/util/OptionalDouble.java b/jdk/src/share/classes/java/util/OptionalDouble.java
index 0efc770fa..9aff9be8d 100644
--- a/jdk/src/share/classes/java/util/OptionalDouble.java
+++ b/jdk/src/share/classes/java/util/OptionalDouble.java
@@ -246,7 +246,7 @@ public final class OptionalDouble {
     @Override
     public String toString() {
         return isPresent
-                ? String.format("OptionalDouble[%s]", value)
+                ? ("OptionalDouble[" + value + "]")
                 : "OptionalDouble.empty";
     }
 }
diff --git a/jdk/src/share/classes/java/util/OptionalInt.java b/jdk/src/share/classes/java/util/OptionalInt.java
index 5cb927524..584f6e2ba 100644
--- a/jdk/src/share/classes/java/util/OptionalInt.java
+++ b/jdk/src/share/classes/java/util/OptionalInt.java
@@ -246,7 +246,7 @@ public final class OptionalInt {
     @Override
     public String toString() {
         return isPresent
-                ? String.format("OptionalInt[%s]", value)
+                ? ("OptionalInt[" + value + "]")
                 : "OptionalInt.empty";
     }
 }
diff --git a/jdk/src/share/classes/java/util/OptionalLong.java b/jdk/src/share/classes/java/util/OptionalLong.java
index 589a59fd3..089f54adf 100644
--- a/jdk/src/share/classes/java/util/OptionalLong.java
+++ b/jdk/src/share/classes/java/util/OptionalLong.java
@@ -246,7 +246,7 @@ public final class OptionalLong {
     @Override
     public String toString() {
         return isPresent
-                ? String.format("OptionalLong[%s]", value)
+                ? ("OptionalLong[" + value + "]")
                 : "OptionalLong.empty";
     }
 }
-- 
2.22.0

