8283465: Character.UnicodeBlock.NUM_ENTITIES is out of date

Reviewed-by: bpb, iris, smarks
This commit is contained in:
Naoto Sato 2022-03-23 19:44:04 +00:00
parent f9137cb7b7
commit 0ee65e1ff3
3 changed files with 55 additions and 75 deletions

View file

@ -737,10 +737,13 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
*/
public static final class UnicodeBlock extends Subset {
/**
* 696 - the expected number of entities
* NUM_ENTITIES should match the total number of UnicodeBlocks
* to calculate the initial capacity of the map. It should be
* adjusted whenever the Unicode Character Database is upgraded.
*
* 0.75 - the default load factor of HashMap
*/
private static final int NUM_ENTITIES = 696;
private static final int NUM_ENTITIES = 737;
private static Map<String, UnicodeBlock> map =
new HashMap<>((int)(NUM_ENTITIES / 0.75f + 1.0f));