Skip to content

Commit ab05354

Browse files
committed
Switch from array to HashMap in object inspection cache.
1 parent cf225ea commit ab05354

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ecma-debugger/objectinspection.6.0/inspectablejsobject.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,12 @@ cls.InspectionsPrototype = function()
941941
{
942942
this.add = function(obj)
943943
{
944-
this._objects.push(obj);
945-
var name = obj.id || obj.name;
946-
if (name)
947-
this[name] = obj;
944+
var id = obj.id || obj.name;
945+
if (id)
946+
{
947+
this[id] = obj;
948+
this._objects[id] = obj;
949+
}
948950
else
949951
throw "The object must have and id or a name";
950952
};
@@ -957,17 +959,18 @@ cls.InspectionsPrototype = function()
957959
*/
958960
this.get_object = function(obj_id)
959961
{
960-
for (var i = 0, object; object = this._objects[i]; i++)
962+
var objects = this._objects;
963+
for (var id in objects)
961964
{
962-
if (object.object_id === obj_id)
963-
return object;
965+
if (objects[id].object_id === obj_id)
966+
return objects[id];
964967
}
965968
return null;
966969
};
967970

968971
this.init = function()
969972
{
970-
this._objects = [];
973+
this._objects = new HashMap();
971974
};
972975
};
973976

0 commit comments

Comments
 (0)