Browse Source

Reflect now use $fasthash

Nicolas Cannasse 13 years ago
parent
commit
7ac263fea7
3 changed files with 9 additions and 7 deletions
  1. 2 1
      doc/CHANGES.txt
  2. 1 0
      interp.ml
  3. 6 6
      std/neko/_std/Reflect.hx

+ 2 - 1
doc/CHANGES.txt

@@ -20,12 +20,13 @@
 	all : allowed abitrary string fields in anonymous objects
 	all : allowed abitrary string fields in anonymous objects
 	all : structure fields which are Null<X> are now optional (for constant values)
 	all : structure fields which are Null<X> are now optional (for constant values)
 	all : allowed optional args in functions types (?Int -> Void)
 	all : allowed optional args in functions types (?Int -> Void)
-	all : added Reflect.getProperty/setProperty 
+	all : added Reflect.getProperty/setProperty
 		(partial support : neko, js only so far)
 		(partial support : neko, js only so far)
 	all : added --cache, --wait and --cwd
 	all : added --cache, --wait and --cwd
 	all : fixed completion in macros calls arguments
 	all : fixed completion in macros calls arguments
 	all : fixed DCE removing empty but still used interfaces/superclasses
 	all : fixed DCE removing empty but still used interfaces/superclasses
 	all : added haxe.Utf8 (crossplatform)
 	all : added haxe.Utf8 (crossplatform)
+	neko : Reflect now uses $fasthash (require neko 1.8.2)
 
 
 2011-09-25: 2.08
 2011-09-25: 2.08
 	js : added js.JQuery
 	js : added js.JQuery

+ 1 - 0
interp.ml

@@ -534,6 +534,7 @@ let builtins =
 			VArray (Array.map (fun (fid,_) -> VInt fid) (vobj o).ofields)
 			VArray (Array.map (fun (fid,_) -> VInt fid) (vobj o).ofields)
 		);
 		);
 		"hash", Fun1 (fun v -> VInt (hash_field (get_ctx()) (vstring v)));
 		"hash", Fun1 (fun v -> VInt (hash_field (get_ctx()) (vstring v)));
+		"fasthash", Fun1 (fun v -> VInt (hash (vstring v)));
 		"field", Fun1 (fun v ->
 		"field", Fun1 (fun v ->
 			try VString (Hashtbl.find (get_ctx()).fields_cache (vint v)) with Not_found -> VNull
 			try VString (Hashtbl.find (get_ctx()).fields_cache (vint v)) with Not_found -> VNull
 		);
 		);

+ 6 - 6
std/neko/_std/Reflect.hx

@@ -26,27 +26,27 @@
 @:core_api class Reflect {
 @:core_api class Reflect {
 
 
 	public static function hasField( o : Dynamic, field : String ) : Bool untyped {
 	public static function hasField( o : Dynamic, field : String ) : Bool untyped {
-		return $typeof(o) == $tobject && $objfield(o,$hash(field.__s));
+		return $typeof(o) == $tobject && $objfield(o,$fasthash(field.__s));
 	}
 	}
 
 
 	public inline static function field( o : Dynamic, field : String ) : Dynamic untyped {
 	public inline static function field( o : Dynamic, field : String ) : Dynamic untyped {
-		return if( $typeof(o) != $tobject ) null else $objget(o,$hash(field.__s));
+		return if( $typeof(o) != $tobject ) null else $objget(o,$fasthash(field.__s));
 	}
 	}
 
 
 	public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped {
 	public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped {
 		if( $typeof(o) == $tobject )
 		if( $typeof(o) == $tobject )
-			$objset(o,$hash(field.__s),value);
+			$objset(o,$fasthash(field.__s),value);
 	}
 	}
 
 
 	public static inline function getProperty( o : Dynamic, field : String ) : Dynamic untyped {
 	public static inline function getProperty( o : Dynamic, field : String ) : Dynamic untyped {
 		var tmp;
 		var tmp;
-		return if( $typeof(o) != $tobject ) null else if( o.__properties__ != null && (tmp=$objget(o.__properties__,$hash("get_".__s+field.__s))) != null ) $call($objget(o,$hash(tmp)),o,$array()) else $objget(o,$hash(field.__s));
+		return if( $typeof(o) != $tobject ) null else if( o.__properties__ != null && (tmp=$objget(o.__properties__,$fasthash("get_".__s+field.__s))) != null ) $call($objget(o,$fasthash(tmp)),o,$array()) else $objget(o,$fasthash(field.__s));
 	}
 	}
 
 
 	public static inline function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void untyped {
 	public static inline function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void untyped {
 		if( $typeof(o) == $tobject ) {
 		if( $typeof(o) == $tobject ) {
 			var tmp;
 			var tmp;
-			if( o.__properties__ != null && (tmp=$objget(o.__properties__,$hash("set_".__s+field.__s))) != null ) $call($objget(o,$hash(tmp)),o,$array(value)) else $objset(o,$hash(field.__s),value);
+			if( o.__properties__ != null && (tmp=$objget(o.__properties__,$fasthash("set_".__s+field.__s))) != null ) $call($objget(o,$fasthash(tmp)),o,$array(value)) else $objset(o,$fasthash(field.__s),value);
 		}
 		}
 	}
 	}
 
 
@@ -86,7 +86,7 @@
 	}
 	}
 
 
 	public inline static function deleteField( o : Dynamic, f : String ) : Bool untyped {
 	public inline static function deleteField( o : Dynamic, f : String ) : Bool untyped {
-		return $objremove(o,$hash(f.__s));
+		return $objremove(o,$fasthash(f.__s));
 	}
 	}
 
 
 	public inline static function copy<T>( o : T ) : T {
 	public inline static function copy<T>( o : T ) : T {