Skip to content

Commit

Permalink
Trivial tweak: set initial capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Jan 11, 2025
1 parent 9e1f90c commit c66f104
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/codehaus/groovy/reflection/CachedClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ public Collection<ClassInfo> initValue() {

@Override
public Set<CachedClass> initValue() {
Set<CachedClass> res = new HashSet<>(0);

Class[] classes = getTheClass().getInterfaces();
Set<CachedClass> res = new HashSet<>(classes.length);
for (Class cls : classes) {
res.add(ReflectionCache.getCachedClass(cls));
}
Expand All @@ -188,12 +187,13 @@ public Set<CachedClass> initValue() {

@Override
public Set<CachedClass> initValue() {
Set<CachedClass> res = new HashSet<>(0);

if (getTheClass().isInterface()) {
Class<?> theClass = getTheClass();
Class[] classes = theClass.getInterfaces();
Set<CachedClass> res = new HashSet<>(classes.length + 8);
if (theClass.isInterface()) {
res.add(CachedClass.this);
}
Class[] classes = getTheClass().getInterfaces();

for (Class cls : classes) {
CachedClass aClass = ReflectionCache.getCachedClass(cls);
if (!res.contains(aClass))
Expand Down

0 comments on commit c66f104

Please sign in to comment.