From 64e0127c640646f0e8967678a19c372636de6f3f Mon Sep 17 00:00:00 2001 From: Valter Strods Date: Sun, 8 Jun 2014 21:41:52 +0300 Subject: libcore: Clean up Enum.compareTo(E) As E extends Enum, 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 --- libart/src/main/java/java/lang/Enum.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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> implements Serializable, Comparabl * @see java.lang.Comparable */ public final int compareTo(E o) { - return ordinal - o.ordinal(); + return ordinal - ((Enum) o).ordinal; } /** -- cgit v1.1