Skip to content

Commit c66f104

Browse files
committed
Trivial tweak: set initial capacity
1 parent 9e1f90c commit c66f104

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/org/codehaus/groovy/reflection/CachedClass.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ public Collection<ClassInfo> initValue() {
173173

174174
@Override
175175
public Set<CachedClass> initValue() {
176-
Set<CachedClass> res = new HashSet<>(0);
177-
178176
Class[] classes = getTheClass().getInterfaces();
177+
Set<CachedClass> res = new HashSet<>(classes.length);
179178
for (Class cls : classes) {
180179
res.add(ReflectionCache.getCachedClass(cls));
181180
}
@@ -188,12 +187,13 @@ public Set<CachedClass> initValue() {
188187

189188
@Override
190189
public Set<CachedClass> initValue() {
191-
Set<CachedClass> res = new HashSet<>(0);
192-
193-
if (getTheClass().isInterface()) {
190+
Class<?> theClass = getTheClass();
191+
Class[] classes = theClass.getInterfaces();
192+
Set<CachedClass> res = new HashSet<>(classes.length + 8);
193+
if (theClass.isInterface()) {
194194
res.add(CachedClass.this);
195195
}
196-
Class[] classes = getTheClass().getInterfaces();
196+
197197
for (Class cls : classes) {
198198
CachedClass aClass = ReflectionCache.getCachedClass(cls);
199199
if (!res.contains(aClass))

0 commit comments

Comments
 (0)