Size equal to 0 or 1 can return directly
private static void sortPostProcessors(List<?> postProcessors, ConfigurableListableBeanFactory beanFactory) {
Comparator<Object> comparatorToUse = null;
if (beanFactory instanceof DefaultListableBeanFactory) {
comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator();
}
if (comparatorToUse == null) {
comparatorToUse = OrderComparator.INSTANCE;
}
postProcessors.sort(comparatorToUse);
}
Comment From: sbrannen
Good catch. We'll optimize this in 5.2.6.
Comment From: quaff
It make code ugly, is it worthy?
Comment From: sbrannen
@quaff, We have implemented similar optimizations recently. See #24617 for details.