diff --git a/Wasm.Dom/wwwroot/js/JSObject.6.0.1.js b/Wasm.Dom/wwwroot/js/JSObject.6.0.1.js index 046c126..d53baef 100644 --- a/Wasm.Dom/wwwroot/js/JSObject.6.0.1.js +++ b/Wasm.Dom/wwwroot/js/JSObject.6.0.1.js @@ -1,6 +1,7 @@ window.nkJSObject = { objectMap: [], + emptySlots: [], RegisterObject: function(obj) { if (obj == null) @@ -8,9 +9,18 @@ if (nkJSObject.objectMap.indexOf(obj) != -1) throw "object already registered"; - nkJSObject.objectMap.push(obj); - var uid = nkJSObject.objectMap.indexOf(obj); - return uid; + if (nkJSObject.emptySlots.length == 0) + { + nkJSObject.objectMap.push(obj); + var uid = nkJSObject.objectMap.lastIndexOf(obj); + return uid; + } + else + { + var uid = nkJSObject.emptySlots.pop(); + nkJSObject.objectMap[uid] = obj; + return uid; + } }, GetObject: function(uid) { @@ -19,6 +29,7 @@ DisposeObject: function(uid) { delete nkJSObject.objectMap[uid]; + nkJSObject.emptySlots.push(uid); }, GetWindow: function() {