Optimize AutoConfigurationImportSelector.filter()
See gh-20928
This commit is contained in:
committed by
Stephane Nicoll
parent
fb2f6bb1af
commit
2158fadb35
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -239,14 +239,12 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector,
|
||||
private List<String> filter(List<String> configurations, AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
long startTime = System.nanoTime();
|
||||
String[] candidates = StringUtils.toStringArray(configurations);
|
||||
boolean[] skip = new boolean[candidates.length];
|
||||
boolean skipped = false;
|
||||
for (AutoConfigurationImportFilter filter : getAutoConfigurationImportFilters()) {
|
||||
invokeAwareMethods(filter);
|
||||
boolean[] match = filter.match(candidates, autoConfigurationMetadata);
|
||||
for (int i = 0; i < match.length; i++) {
|
||||
if (!match[i]) {
|
||||
skip[i] = true;
|
||||
candidates[i] = null;
|
||||
skipped = true;
|
||||
}
|
||||
@@ -257,7 +255,7 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector,
|
||||
}
|
||||
List<String> result = new ArrayList<>(candidates.length);
|
||||
for (int i = 0; i < candidates.length; i++) {
|
||||
if (!skip[i]) {
|
||||
if (candidates[i] != null) {
|
||||
result.add(candidates[i]);
|
||||
}
|
||||
}
|
||||
@@ -266,7 +264,7 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector,
|
||||
logger.trace("Filtered " + numberFiltered + " auto configuration class in "
|
||||
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) + " ms");
|
||||
}
|
||||
return new ArrayList<>(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() {
|
||||
|
||||
Reference in New Issue
Block a user