summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValter Strods <valters.strods@gmail.com>2014-06-08 21:41:52 +0300
committerValter Strods <valters.strods@gmail.com>2014-06-24 10:00:34 +0300
commit64e0127c640646f0e8967678a19c372636de6f3f (patch)
treee7e8854108d2d65b2551f2337a733a9b31286016
parentcb8217586ab2f6d88d75a563cbfb7cd57e746bd3 (diff)
downloadlibcore-64e0127c640646f0e8967678a19c372636de6f3f.zip
libcore-64e0127c640646f0e8967678a19c372636de6f3f.tar.gz
libcore-64e0127c640646f0e8967678a19c372636de6f3f.tar.bz2
libcore: Clean up Enum.compareTo(E)
As E extends Enum<E>, it is safe to cast the comparable object to Enum<?> as it should not throw any exceptions. When it is cast, the ordinal value can be accessed directly. Doing so would be preferred as either both the variables this.ordinal and o.ordinal should be used or the methods this.ordinal() and o.ordinal() should be used without mixing them together. Change-Id: I7c4e93fdf35b0bf2949738a91c0855d9a52e5c13
-rw-r--r--libart/src/main/java/java/lang/Enum.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/libart/src/main/java/java/lang/Enum.java b/libart/src/main/java/java/lang/Enum.java
index e9545a1..ac5fc9a 100644
--- a/libart/src/main/java/java/lang/Enum.java
+++ b/libart/src/main/java/java/lang/Enum.java
@@ -149,7 +149,7 @@ public abstract class Enum<E extends Enum<E>> implements Serializable, Comparabl
* @see java.lang.Comparable
*/
public final int compareTo(E o) {
- return ordinal - o.ordinal();
+ return ordinal - ((Enum<?>) o).ordinal;
}
/**