1 Star 0 Fork 81

zhaosai/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0045-8276904-Optional.toString-is-unnecessarily-expensive.patch 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhaosai-Simon/openjdk-1.8.0.git
git@gitee.com:zhaosai-Simon/openjdk-1.8.0.git
zhaosai-Simon
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助