Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
71d391a6
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
71d391a6
编写于
6月 12, 2014
作者:
S
scolebourne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8046707: Performance of java.time could be better
Summary: Optimise performance Reviewed-by: rriggs
上级
b44cf83b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
21 deletion
+30
-21
src/share/classes/java/time/Instant.java
src/share/classes/java/time/Instant.java
+2
-1
src/share/classes/java/time/OffsetDateTime.java
src/share/classes/java/time/OffsetDateTime.java
+5
-4
src/share/classes/java/time/ZonedDateTime.java
src/share/classes/java/time/ZonedDateTime.java
+10
-5
src/share/classes/java/time/format/Parsed.java
src/share/classes/java/time/format/Parsed.java
+13
-11
未找到文件。
src/share/classes/java/time/Instant.java
浏览文件 @
71d391a6
...
...
@@ -1058,7 +1058,8 @@ public final class Instant
}
// inline TemporalAccessor.super.query(query) as an optimization
if
(
query
==
TemporalQueries
.
chronology
()
||
query
==
TemporalQueries
.
zoneId
()
||
query
==
TemporalQueries
.
zone
()
||
query
==
TemporalQueries
.
offset
())
{
query
==
TemporalQueries
.
zone
()
||
query
==
TemporalQueries
.
offset
()
||
query
==
TemporalQueries
.
localDate
()
||
query
==
TemporalQueries
.
localTime
())
{
return
null
;
}
return
query
.
queryFrom
(
this
);
...
...
src/share/classes/java/time/OffsetDateTime.java
浏览文件 @
71d391a6
...
...
@@ -357,10 +357,11 @@ public final class OffsetDateTime
}
try
{
ZoneOffset
offset
=
ZoneOffset
.
from
(
temporal
);
try
{
LocalDateTime
ldt
=
LocalDateTime
.
from
(
temporal
);
return
OffsetDateTime
.
of
(
ldt
,
offset
);
}
catch
(
DateTimeException
ignore
)
{
LocalDate
date
=
temporal
.
query
(
TemporalQueries
.
localDate
());
LocalTime
time
=
temporal
.
query
(
TemporalQueries
.
localTime
());
if
(
date
!=
null
&&
time
!=
null
)
{
return
OffsetDateTime
.
of
(
date
,
time
,
offset
);
}
else
{
Instant
instant
=
Instant
.
from
(
temporal
);
return
OffsetDateTime
.
ofInstant
(
instant
,
offset
);
}
...
...
src/share/classes/java/time/ZonedDateTime.java
浏览文件 @
71d391a6
...
...
@@ -81,6 +81,7 @@ import java.time.temporal.TemporalAccessor;
import
java.time.temporal.TemporalAdjuster
;
import
java.time.temporal.TemporalAmount
;
import
java.time.temporal.TemporalField
;
import
java.time.temporal.TemporalQueries
;
import
java.time.temporal.TemporalQuery
;
import
java.time.temporal.TemporalUnit
;
import
java.time.temporal.UnsupportedTemporalTypeException
;
...
...
@@ -550,14 +551,14 @@ public final class ZonedDateTime
}
try
{
ZoneId
zone
=
ZoneId
.
from
(
temporal
);
try
{
if
(
temporal
.
isSupported
(
INSTANT_SECONDS
))
{
long
epochSecond
=
temporal
.
getLong
(
INSTANT_SECONDS
);
int
nanoOfSecond
=
temporal
.
get
(
NANO_OF_SECOND
);
return
create
(
epochSecond
,
nanoOfSecond
,
zone
);
}
catch
(
DateTimeException
ex1
)
{
Local
DateTime
ldt
=
LocalDate
Time
.
from
(
temporal
);
return
of
(
ldt
,
zone
);
}
else
{
LocalDate
date
=
LocalDate
.
from
(
temporal
);
Local
Time
time
=
Local
Time
.
from
(
temporal
);
return
of
(
date
,
time
,
zone
);
}
}
catch
(
DateTimeException
ex
)
{
throw
new
DateTimeException
(
"Unable to obtain ZonedDateTime from TemporalAccessor: "
+
...
...
@@ -2037,8 +2038,12 @@ public final class ZonedDateTime
* @throws DateTimeException if unable to query (defined by the query)
* @throws ArithmeticException if numeric overflow occurs (defined by the query)
*/
@SuppressWarnings
(
"unchecked"
)
@Override
// override for Javadoc
public
<
R
>
R
query
(
TemporalQuery
<
R
>
query
)
{
if
(
query
==
TemporalQueries
.
localDate
())
{
return
(
R
)
toLocalDate
();
}
return
ChronoZonedDateTime
.
super
.
query
(
query
);
}
...
...
src/share/classes/java/time/format/Parsed.java
浏览文件 @
71d391a6
...
...
@@ -635,18 +635,20 @@ final class Parsed implements TemporalAccessor {
for
(
Iterator
<
Entry
<
TemporalField
,
Long
>>
it
=
fieldValues
.
entrySet
().
iterator
();
it
.
hasNext
();
)
{
Entry
<
TemporalField
,
Long
>
entry
=
it
.
next
();
TemporalField
field
=
entry
.
getKey
();
long
val1
;
try
{
val1
=
target
.
getLong
(
field
);
}
catch
(
RuntimeException
ex
)
{
continue
;
}
long
val2
=
entry
.
getValue
();
if
(
val1
!=
val2
)
{
throw
new
DateTimeException
(
"Conflict found: Field "
+
field
+
" "
+
val1
+
" differs from "
+
field
+
" "
+
val2
+
" derived from "
+
target
);
if
(
target
.
isSupported
(
field
))
{
long
val1
;
try
{
val1
=
target
.
getLong
(
field
);
}
catch
(
RuntimeException
ex
)
{
continue
;
}
long
val2
=
entry
.
getValue
();
if
(
val1
!=
val2
)
{
throw
new
DateTimeException
(
"Conflict found: Field "
+
field
+
" "
+
val1
+
" differs from "
+
field
+
" "
+
val2
+
" derived from "
+
target
);
}
it
.
remove
();
}
it
.
remove
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录