Skip to content

Commit 737dcd6

Browse files
committed
Add a method to retrieve inspection objects, and use this to check if the objects lives in the cache instead of recreating the model every time.
1 parent a6dbba6 commit 737dcd6

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ cls.EcmascriptDebugger["6.0"].InspectableJSObject.prototype = new function()
9191
this.id = this._get_id();
9292
if (!window.inspections)
9393
{
94-
new cls.Namespace("inspections");
94+
window.inspections = new cls.Inspections();
9595
}
9696
window.inspections.add(this);
9797
this._obj_map =
@@ -931,3 +931,45 @@ cls.EcmascriptDebugger["6.0"].InspectableJSObject.prototype = new function()
931931
};
932932

933933
}).apply(cls.EcmascriptDebugger["6.0"].InspectableJSObject);
934+
935+
cls.Inspections = function()
936+
{
937+
this.init();
938+
};
939+
940+
cls.InspectionsPrototype = function()
941+
{
942+
this.add = function(obj)
943+
{
944+
this.objects.push(obj);
945+
var name = obj.id || obj.name;
946+
if (name)
947+
this[name] = obj;
948+
else
949+
throw "The object must have and id or a name";
950+
};
951+
952+
/**
953+
* While this is guaranteed to return the correct object, there's no
954+
* guarantee that the correct model is returned. In other words, don't
955+
* rely in this for things that are dependent on the state, e.g. the
956+
* expanded state.
957+
*/
958+
this.get_object = function(rt_id, obj_id)
959+
{
960+
for (var i = 0, object; object = this.objects[i]; i++)
961+
{
962+
if (object.runtime_id === rt_id && object.object_id === obj_id)
963+
return object;
964+
}
965+
return null;
966+
};
967+
968+
this.init = function()
969+
{
970+
this.objects = [];
971+
};
972+
};
973+
974+
cls.Inspections.prototype = new cls.InspectionsPrototype();
975+

src/ecma-debugger/templates.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,14 @@
459459
}
460460

461461
var object = retval.functionFrom;
462-
var func_model = new cls.InspectableJSObject(rt_id,
463-
object.objectID,
464-
object.functionName || ui_strings.S_ANONYMOUS_FUNCTION_NAME,
465-
object.className);
462+
var func_model = window.inspections.get_object(rt_id, object.objectID);
463+
if (!func_model)
464+
{
465+
func_model = new cls.InspectableJSObject(rt_id,
466+
object.objectID,
467+
object.functionName || ui_strings.S_ANONYMOUS_FUNCTION_NAME,
468+
object.className);
469+
}
466470
var func_search_term = value_template.length ? null : search_term;
467471
var func = window.templates.inspected_js_object(func_model, true, null, func_search_term);
468472

0 commit comments

Comments
 (0)