Browse Source

[java/cs] Optimize Reflect.isEnumValue

Caue Waneck 12 years ago
parent
commit
d231fd8696
2 changed files with 10 additions and 4 deletions
  1. 5 2
      std/cs/_std/Reflect.hx
  2. 5 2
      std/java/_std/Reflect.hx

+ 5 - 2
std/cs/_std/Reflect.hx

@@ -207,13 +207,16 @@ import cs.internal.Function;
 
 	**/
 	@:functionCode('
-		return v != null && !(v is haxe.lang.DynamicObject || v is haxe.lang.Function);
+		return v != null && !(v is haxe.lang.DynamicObject || v is haxe.lang.Function || v is System.Enum);
 	')
 	public static function isObject( v : Dynamic ) : Bool
 	{
 		return false;
 	}
-	
+
+	@:functionCode('
+		return v != null && (v is haxe.lang.Enum || v is System.Enum);
+	')
 	public static function isEnumValue( v : Dynamic ) : Bool {
 		return switch(Type.typeof(v)) {
 			case TEnum(_): true;

+ 5 - 2
std/java/_std/Reflect.hx

@@ -209,13 +209,16 @@ import java.Boot;
 
 	**/
 	@:functionCode('
-		return v != null && !(v instanceof haxe.lang.Enum || v instanceof haxe.lang.Function);
+		return v != null && !(v instanceof haxe.lang.Enum || v instanceof haxe.lang.Function || v instanceof java.lang.Enum);
 	')
 	public static function isObject( v : Dynamic ) : Bool
 	{
 		return false;
 	}
-	
+
+	@:functionCode('
+		return v != null && (v instanceof haxe.lang.Enum || v instanceof java.lang.Enum);
+	')
 	public static function isEnumValue( v : Dynamic ) : Bool {
 		return switch(Type.typeof(v)) {
 			case TEnum(_): true;