< prev index next >
src/java.base/share/classes/java/lang/Class.java
Print this page
rev 49518 : [mq]: 8200696-Optimal-initial-capacity-of-java-lang-Class-enumConstantDirectory
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -3527,11 +3527,11 @@
if (directory == null) {
T[] universe = getEnumConstantsShared();
if (universe == null)
throw new IllegalArgumentException(
getName() + " is not an enum type");
- directory = new HashMap<>(2 * universe.length);
+ directory = new HashMap<>((int)(universe.length / 0.75f + 1.0f));
for (T constant : universe) {
directory.put(((Enum<?>)constant).name(), constant);
}
enumConstantDirectory = directory;
}
< prev index next >