From 574dffb60b52c7cb708a436b2939def65b94d0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E6=9C=A8=E4=BB=8A=E5=B1=B1?= Date: Tue, 23 Apr 2019 18:48:21 +0800 Subject: [PATCH] Some trivial optimization in method populateBean() (#22792) Optimize the number of getResolvedAutowireMode() method calls --- .../support/AbstractAutowireCapableBeanFactory.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 09db1fb4ac..beb00f5078 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -1388,14 +1388,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac PropertyValues pvs = (mbd.hasPropertyValues() ? mbd.getPropertyValues() : null); - if (mbd.getResolvedAutowireMode() == AUTOWIRE_BY_NAME || mbd.getResolvedAutowireMode() == AUTOWIRE_BY_TYPE) { + int resolvedAutowireMode = mbd.getResolvedAutowireMode(); + if (resolvedAutowireMode == AUTOWIRE_BY_NAME || resolvedAutowireMode == AUTOWIRE_BY_TYPE) { MutablePropertyValues newPvs = new MutablePropertyValues(pvs); // Add property values based on autowire by name if applicable. - if (mbd.getResolvedAutowireMode() == AUTOWIRE_BY_NAME) { + if (resolvedAutowireMode == AUTOWIRE_BY_NAME) { autowireByName(beanName, mbd, bw, newPvs); } // Add property values based on autowire by type if applicable. - if (mbd.getResolvedAutowireMode() == AUTOWIRE_BY_TYPE) { + if (resolvedAutowireMode == AUTOWIRE_BY_TYPE) { autowireByType(beanName, mbd, bw, newPvs); } pvs = newPvs;