changeset 59181:010615cc8bdb

8244459: Optimize the hash map size in LocaleProviderAdapters Reviewed-by: joehw, plevart, smarks
author naoto
date Wed, 06 May 2020 10:26:22 -0700
parents 5802f4f2c75f
children e4f974647009
files src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Wed May 06 17:33:32 2020 +0100
+++ b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Wed May 06 10:26:22 2020 -0700
@@ -225,7 +225,7 @@
             return Collections.emptySet();
         }
         StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
-        Set<String> tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16));
+        Set<String> tagset = new HashSet<>((tokens.countTokens() * 4 + 2) / 3);
         while (tokens.hasMoreTokens()) {
             tagset.add(tokens.nextToken());
         }
--- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java	Wed May 06 17:33:32 2020 +0100
+++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java	Wed May 06 10:26:22 2020 -0700
@@ -445,7 +445,7 @@
             return Collections.emptySet();
         }
         StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
-        Set<String> tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16));
+        Set<String> tagset = new HashSet<>((tokens.countTokens() * 4 + 2) / 3);
         while (tokens.hasMoreTokens()) {
             tagset.add(tokens.nextToken());
         }