From 62ca7c4e8fa26d7eaa413c57aa232321d94d47f8 Mon Sep 17 00:00:00 2001 From: stsypanov Date: Sat, 23 Nov 2019 23:19:42 +0200 Subject: [PATCH] Hoist constant byte[] out of loop --- .../java/org/springframework/beans/ExtendedBeanInfo.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 13320a607d..3639949dbc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -208,7 +208,7 @@ class ExtendedBeanInfo implements BeanInfo { } private String propertyNameFor(Method method) { - return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); + return Introspector.decapitalize(method.getName().substring(3)); } @@ -534,11 +534,13 @@ class ExtendedBeanInfo implements BeanInfo { public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) { String left = desc1.getName(); String right = desc2.getName(); + byte[] leftBytes = left.getBytes(); + byte[] rightBytes = right.getBytes(); for (int i = 0; i < left.length(); i++) { if (right.length() == i) { return 1; } - int result = left.getBytes()[i] - right.getBytes()[i]; + int result = leftBytes[i] - rightBytes[i]; if (result != 0) { return result; }