Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 2ebf5a2

Browse files
committedApr 30, 2020
8244152: Remove unnecessary hash map resize in LocaleProviderAdapters
Reviewed-by: joehw, vtewari
1 parent a15b1ea commit 2ebf5a2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -224,8 +224,8 @@ protected Set<String> createLanguageTagSet(String category) {
224224
if (supportedLocaleString == null) {
225225
return Collections.emptySet();
226226
}
227-
Set<String> tagset = new HashSet<>();
228227
StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
228+
Set<String> tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16));
229229
while (tokens.hasMoreTokens()) {
230230
tagset.add(tokens.nextToken());
231231
}

‎src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -444,8 +444,8 @@ protected Set<String> createLanguageTagSet(String category) {
444444
if (supportedLocaleString == null) {
445445
return Collections.emptySet();
446446
}
447-
Set<String> tagset = new HashSet<>();
448447
StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
448+
Set<String> tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16));
449449
while (tokens.hasMoreTokens()) {
450450
tagset.add(tokens.nextToken());
451451
}

0 commit comments

Comments
 (0)
This repository has been archived.