Skip to content

Commit

Permalink
Hoist constant byte[] out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
stsypanov authored and jhoeller committed Nov 27, 2019
1 parent 52630b0 commit 62ca7c4
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, C
}

private String propertyNameFor(Method method) {
return Introspector.decapitalize(method.getName().substring(3, method.getName().length()));
return Introspector.decapitalize(method.getName().substring(3));
}


Expand Down Expand Up @@ -534,11 +534,13 @@ static class PropertyDescriptorComparator implements Comparator<PropertyDescript
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;
}
Expand Down

0 comments on commit 62ca7c4

Please sign in to comment.