Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize sortPostProcessors() in PostProcessorRegistrationDelegate #24776

Closed
cherishsince opened this issue Mar 25, 2020 · 3 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@cherishsince
Copy link

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);
	}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 25, 2020
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 25, 2020
@sbrannen sbrannen self-assigned this Mar 25, 2020
@sbrannen sbrannen added this to the 5.2.6 milestone Mar 25, 2020
@sbrannen
Copy link
Member

Good catch. We'll optimize this in 5.2.6.

@sbrannen sbrannen changed the title PostProcessorRegistrationDelegate.sortPostProcessors Optimize sortPostProcessors() in PostProcessorRegistrationDelegate Mar 25, 2020
@quaff
Copy link
Contributor

quaff commented Mar 26, 2020

It make code ugly, is it worthy?

@sbrannen
Copy link
Member

@quaff, We have implemented similar optimizations recently. See #24617 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants