Explorar o código

use class as an underlying type for haxe.ds.HashMap to avoid dynamic lookup on static platforms.

also, inline the constructor so the object can be inlined.
Dan Korostelev %!s(int64=10) %!d(string=hai) anos
pai
achega
669cb86860
Modificáronse 1 ficheiros con 12 adicións e 3 borrados
  1. 12 3
      std/haxe/ds/HashMap.hx

+ 12 - 3
std/haxe/ds/HashMap.hx

@@ -21,9 +21,9 @@
  */
 package haxe.ds;
 
-abstract HashMap<K:{ function hashCode():Int; }, V >({keys:IntMap<K>, values:IntMap<V>}) {
-	public function new() {
-		this = { keys:new IntMap(), values: new IntMap() };
+abstract HashMap<K:{ function hashCode():Int; }, V >(HashMapData<K,V>) {
+	public inline function new() {
+		this = new HashMapData();
 	}
 	public inline function set(k:K, v:V) {
 		this.keys.set(k.hashCode(), k);
@@ -45,4 +45,13 @@ abstract HashMap<K:{ function hashCode():Int; }, V >({keys:IntMap<K>, values:Int
 	public inline function iterator() {
 		return this.values.iterator();
 	}
+}
+
+private class HashMapData<K:{ function hashCode():Int; },V> {
+	public var keys:IntMap<K>;
+	public var values:IntMap<V>;
+	public inline function new() {
+		keys = new IntMap();
+		values = new IntMap();
+	}
 }