< prev index next >

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

Print this page
rev 59021 : 8244152: Remove unnecessary hash map resize in LocaleProviderAdapters
Reviewed-by: joehw, vtewari

*** 1,7 **** /* ! * Copyright (c) 2012, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2012, 2020, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 442,453 **** protected Set<String> createLanguageTagSet(String category) { String supportedLocaleString = createSupportedLocaleString(category); if (supportedLocaleString == null) { return Collections.emptySet(); } - Set<String> tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); while (tokens.hasMoreTokens()) { tagset.add(tokens.nextToken()); } return tagset; --- 442,453 ---- protected Set<String> createLanguageTagSet(String category) { String supportedLocaleString = createSupportedLocaleString(category); if (supportedLocaleString == null) { return Collections.emptySet(); } StringTokenizer tokens = new StringTokenizer(supportedLocaleString); + Set<String> tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16)); while (tokens.hasMoreTokens()) { tagset.add(tokens.nextToken()); } return tagset;
< prev index next >