Browse Source

Faster version of ValueType check in Null

Dan Ogles 10 years ago
parent
commit
b254ba7842
1 changed files with 9 additions and 1 deletions
  1. 9 1
      std/cs/internal/Null.hx

+ 9 - 1
std/cs/internal/Null.hx

@@ -21,6 +21,14 @@
  */
 package cs.internal;
 
+@:classCode('
+	static public readonly System.Type Type = typeof(T);
+	static public readonly bool IsValueType = haxe.lang.NullMetadata<T>.Type.IsValueType;
+')
+@:keep @:nativeGen @:native("haxe.lang.NullMetadata") private class NullMetadata<T>
+{
+}
+
 @:classCode('
 	//This function is here to be used with Reflection, when the haxe.lang.Null type is known
 	public static haxe.lang.Null<T> _ofDynamic(object obj)
@@ -47,7 +55,7 @@ package cs.internal;
 	@:readOnly public var hasValue(default,never):Bool;
 
 	@:functionCode('
-			if (!typeof(T).IsValueType && System.Object.ReferenceEquals(v, default(T)))
+			if (!haxe.lang.NullMetadata<T>.IsValueType && System.Object.ReferenceEquals(v, default(T)))
 			{
 				hasValue = false;
 			}