File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class HeapSnapshotManager {
2323 {
2424 snapshot : DevTools . HeapSnapshotModel . HeapSnapshotProxy . HeapSnapshotProxy ;
2525 worker : DevTools . HeapSnapshotModel . HeapSnapshotProxy . HeapSnapshotWorkerProxy ;
26+ // TODO: use a multimap
2627 uidToClassKey : Map < number , string > ;
2728 classKeyToUid : Map < string , number > ;
2829 idGenerator : ( ) => number ;
@@ -84,6 +85,20 @@ export class HeapSnapshotManager {
8485 return snapshot . staticData ;
8586 }
8687
88+ async getOrCreateUidForClassKey (
89+ filePath : string ,
90+ classKey : string ,
91+ ) : Promise < number > {
92+ const cached = this . #getCachedSnapshot( filePath ) ;
93+ let uid = cached . classKeyToUid . get ( classKey ) ;
94+ if ( ! uid ) {
95+ uid = cached . idGenerator ( ) ;
96+ cached . classKeyToUid . set ( classKey , uid ) ;
97+ cached . uidToClassKey . set ( uid , classKey ) ;
98+ }
99+ return uid ;
100+ }
101+
87102 async #loadSnapshot( absolutePath : string ) : Promise < {
88103 snapshot : DevTools . HeapSnapshotModel . HeapSnapshotProxy . HeapSnapshotProxy ;
89104 worker : DevTools . HeapSnapshotModel . HeapSnapshotProxy . HeapSnapshotWorkerProxy ;
You can’t perform that action at this time.
0 commit comments