Author: kpreisser
Date: Fri Apr 25 20:53:22 2014
New Revision: 1590138
URL: http://svn.apache.org/r1590138
Log:
Follow-Up to r1590120:
Simplify code by using Integer.compare(int, int) which is available since Java
1.7.
Modified:
tomcat/trunk/java/javax/el/Util.java
tomcat/trunk/java/org/apache/el/util/ReflectionUtil.java
Modified: tomcat/trunk/java/javax/el/Util.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/Util.java?rev=1590138&r1=1590137&r2=1590138&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/Util.java (original)
+++ tomcat/trunk/java/javax/el/Util.java Fri Apr 25 20:53:22 2014
@@ -741,25 +741,14 @@ class Util {
@Override
public int compareTo(MatchResult o) {
- if (this.getExact() < o.getExact()) {
- return -1;
- } else if (this.getExact() > o.getExact()) {
- return 1;
- } else {
- if (this.getAssignable() < o.getAssignable()) {
- return -1;
- } else if (this.getAssignable() > o.getAssignable()) {
- return 1;
- } else {
- if (this.getCoercible() < o.getCoercible()) {
- return -1;
- } else if (this.getCoercible() > o.getCoercible()) {
- return 1;
- } else {
- return 0;
- }
+ int cmp = Integer.compare(this.getExact(), o.getExact());
+ if (cmp == 0) {
+ cmp = Integer.compare(this.getAssignable(), o.getAssignable());
+ if (cmp == 0) {
+ cmp = Integer.compare(this.getCoercible(),
o.getCoercible());
}
}
+ return cmp;
}
}
}
Modified: tomcat/trunk/java/org/apache/el/util/ReflectionUtil.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/util/ReflectionUtil.java?rev=1590138&r1=1590137&r2=1590138&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/util/ReflectionUtil.java (original)
+++ tomcat/trunk/java/org/apache/el/util/ReflectionUtil.java Fri Apr 25
20:53:22 2014
@@ -471,25 +471,14 @@ public class ReflectionUtil {
@Override
public int compareTo(MatchResult o) {
- if (this.getExact() < o.getExact()) {
- return -1;
- } else if (this.getExact() > o.getExact()) {
- return 1;
- } else {
- if (this.getAssignable() < o.getAssignable()) {
- return -1;
- } else if (this.getAssignable() > o.getAssignable()) {
- return 1;
- } else {
- if (this.getCoercible() < o.getCoercible()) {
- return -1;
- } else if (this.getCoercible() > o.getCoercible()) {
- return 1;
- } else {
- return 0;
- }
+ int cmp = Integer.compare(this.getExact(), o.getExact());
+ if (cmp == 0) {
+ cmp = Integer.compare(this.getAssignable(), o.getAssignable());
+ if (cmp == 0) {
+ cmp = Integer.compare(this.getCoercible(),
o.getCoercible());
}
}
+ return cmp;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]