|
@@ -25,7 +25,12 @@ package haxe.ds;
|
|
@:coreApi
|
|
@:coreApi
|
|
class ObjectMap<K:{ }, V> implements haxe.Constraints.IMap<K,V> {
|
|
class ObjectMap<K:{ }, V> implements haxe.Constraints.IMap<K,V> {
|
|
|
|
|
|
- static var count = 0;
|
|
|
|
|
|
+ static var count:Int;
|
|
|
|
+
|
|
|
|
+ // initialize count through __init__ magic, because these are generated
|
|
|
|
+ // before normal static initializations for which ObjectMap should be ready to use
|
|
|
|
+ // see https://github.com/HaxeFoundation/haxe/issues/6792
|
|
|
|
+ static inline function __init__():Void count = 0;
|
|
|
|
|
|
static inline function assignId(obj: { } ):Int {
|
|
static inline function assignId(obj: { } ):Int {
|
|
return untyped obj.__id__ = ++count;
|
|
return untyped obj.__id__ = ++count;
|
|
@@ -82,7 +87,7 @@ class ObjectMap<K:{ }, V> implements haxe.Constraints.IMap<K,V> {
|
|
next : function() { var i = __this__.it.next(); return __this__.ref[getId(i)]; }
|
|
next : function() { var i = __this__.it.next(); return __this__.ref[getId(i)]; }
|
|
};
|
|
};
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function copy() : ObjectMap<K,V> {
|
|
public function copy() : ObjectMap<K,V> {
|
|
var copied = new ObjectMap();
|
|
var copied = new ObjectMap();
|
|
for(key in keys()) copied.set(key, get(key));
|
|
for(key in keys()) copied.set(key, get(key));
|