瀏覽代碼

optimized "remove" by using __in__ instead of hasOwnProperty

Nicolas Cannasse 11 年之前
父節點
當前提交
22cd6d4439
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      std/flash/_std/haxe/ds/IntMap.hx
  2. 1 1
      std/flash/_std/haxe/ds/StringMap.hx

+ 1 - 1
std/flash/_std/haxe/ds/IntMap.hx

@@ -42,7 +42,7 @@ package haxe.ds;
 	}
 
 	public function remove( key : Int ) : Bool {
-		if( untyped !h.hasOwnProperty(key) ) return false;
+		if( !exists(key) ) return false;
 		untyped __delete__(h,key);
 		return true;
 	}

+ 1 - 1
std/flash/_std/haxe/ds/StringMap.hx

@@ -43,7 +43,7 @@ package haxe.ds;
 
 	public function remove( key : String ) : Bool {
 		key = "$"+key;
-		if( untyped !h.hasOwnProperty(key) ) return false;
+		if( untyped !__in__(key,h) ) return false;
 		untyped __delete__(h,key);
 		return true;
 	}