mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8288723: Avoid redundant ConcurrentHashMap.get call in java.time
Reviewed-by: attila, rriggs
This commit is contained in:
parent
3582fd9e93
commit
52cc6cd063
4 changed files with 14 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -309,13 +309,7 @@ class DateTimeTextProvider {
|
|||
|
||||
private Object findStore(TemporalField field, Locale locale) {
|
||||
Entry<TemporalField, Locale> key = createEntry(field, locale);
|
||||
Object store = CACHE.get(key);
|
||||
if (store == null) {
|
||||
store = createStore(field, locale);
|
||||
CACHE.putIfAbsent(key, store);
|
||||
store = CACHE.get(key);
|
||||
}
|
||||
return store;
|
||||
return CACHE.computeIfAbsent(key, e -> createStore(e.getKey(), e.getValue()));
|
||||
}
|
||||
|
||||
private static int toWeekDay(int calWeekDay) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -160,13 +160,7 @@ public final class DecimalStyle {
|
|||
*/
|
||||
public static DecimalStyle of(Locale locale) {
|
||||
Objects.requireNonNull(locale, "locale");
|
||||
DecimalStyle info = CACHE.get(locale);
|
||||
if (info == null) {
|
||||
info = create(locale);
|
||||
CACHE.putIfAbsent(locale, info);
|
||||
info = CACHE.get(locale);
|
||||
}
|
||||
return info;
|
||||
return CACHE.computeIfAbsent(locale, DecimalStyle::create);
|
||||
}
|
||||
|
||||
private static DecimalStyle create(Locale locale) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue