|
63 | 63 | import com.cedarsoftware.util.ClassUtilities; |
64 | 64 | import com.cedarsoftware.util.ClassValueMap; |
65 | 65 | import com.cedarsoftware.util.IdentitySet; |
66 | | -import com.cedarsoftware.util.MultiKeyMap; |
67 | 66 | import com.cedarsoftware.util.geom.Color; |
68 | 67 | import com.cedarsoftware.util.geom.Dimension; |
69 | 68 | import com.cedarsoftware.util.geom.Insets; |
@@ -204,10 +203,7 @@ public final class Converter { |
204 | 203 | public static final String PRECISION_NANOS = "nanos"; |
205 | 204 | private static final Map<Class<?>, SortedSet<ClassLevel>> cacheParentTypes = new ClassValueMap<>(); |
206 | 205 | private static final Map<Class<?>, SortedSet<ClassLevel>> cacheCompleteHierarchy = new ClassValueMap<>(); |
207 | | - private static final MultiKeyMap<InheritancePair[]> cacheInheritancePairs = MultiKeyMap.<InheritancePair[]>builder() |
208 | | - .flattenDimensions(true) |
209 | | - .collectionKeyMode(MultiKeyMap.CollectionKeyMode.COLLECTIONS_NOT_EXPANDED) |
210 | | - .build(); |
| 206 | + private static final Map<ConversionPair, InheritancePair[]> cacheInheritancePairs = new ConcurrentHashMap<>(256, 0.75f); |
211 | 207 | private static final Map<ConversionPair, Convert<?>> CONVERSION_DB = new ConcurrentHashMap<>(4096, 0.8f); |
212 | 208 | private final Map<ConversionPair, Convert<?>> USER_DB = new ConcurrentHashMap<>(16, 0.8f); |
213 | 209 | private static final Map<ConversionPair, Convert<?>> FULL_CONVERSION_CACHE = new ConcurrentHashMap<>(1024, 0.75f); |
@@ -1991,7 +1987,7 @@ private static SortedSet<ClassLevel> getCompleteTypeHierarchy(Class<?> clazz) { |
1991 | 1987 | * @return Cached, sorted array of InheritancePair objects |
1992 | 1988 | */ |
1993 | 1989 | private static InheritancePair[] getSortedInheritancePairs(Class<?> sourceType, Class<?> toType) { |
1994 | | - Object[] key = {sourceType, toType}; |
| 1990 | + ConversionPair key = pair(sourceType, toType, 0L); |
1995 | 1991 | InheritancePair[] cached = cacheInheritancePairs.get(key); |
1996 | 1992 | if (cached != null) { |
1997 | 1993 | return cached; |
@@ -2047,8 +2043,8 @@ private static InheritancePair[] getSortedInheritancePairs(Class<?> sourceType, |
2047 | 2043 | }); |
2048 | 2044 |
|
2049 | 2045 | InheritancePair[] pairsArray = pairs.toArray(new InheritancePair[0]); |
2050 | | - cacheInheritancePairs.putMultiKey(pairsArray, sourceType, toType); |
2051 | | - return pairsArray; |
| 2046 | + InheritancePair[] existing = cacheInheritancePairs.putIfAbsent(key, pairsArray); |
| 2047 | + return existing != null ? existing : pairsArray; |
2052 | 2048 | } |
2053 | 2049 |
|
2054 | 2050 | /** |
|
0 commit comments