GH-1149 - Optimize performance for application module lookups by type.
We now avoid immediately resorting to a by type name lookup that triggers extensive search to be able to support simple class names.
This commit is contained in:
@@ -341,7 +341,7 @@ public class ApplicationModule implements Comparable<ApplicationModule> {
|
||||
* @param type must not be {@literal null}.
|
||||
*/
|
||||
public boolean contains(JavaClass type) {
|
||||
return contains(type.getName());
|
||||
return classes.contains(type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +350,7 @@ public class ApplicationModule implements Comparable<ApplicationModule> {
|
||||
* @param type must not be {@literal null}.
|
||||
*/
|
||||
public boolean contains(Class<?> type) {
|
||||
return contains(type.getName());
|
||||
return classes.contains(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -412,7 +412,10 @@ public class ApplicationModules implements Iterable<ApplicationModule> {
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public Optional<ApplicationModule> getModuleByType(Class<?> candidate) {
|
||||
return getModuleByType(candidate.getName());
|
||||
|
||||
return allModules()
|
||||
.filter(it -> it.contains(candidate))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -172,7 +172,11 @@ class Classes implements DescribedIterable<JavaClass> {
|
||||
}
|
||||
|
||||
boolean contains(JavaClass type) {
|
||||
return !that(new SameClass(type)).isEmpty();
|
||||
return classes.contains(type);
|
||||
}
|
||||
|
||||
boolean contains(Class<?> type) {
|
||||
return classes.stream().anyMatch(it -> it.isEquivalentTo(type));
|
||||
}
|
||||
|
||||
boolean contains(String className) {
|
||||
|
||||
Reference in New Issue
Block a user