mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-17 18:17:29 +03:00
Remove used callbacks in debug adapter
Summary: Release note: none For each debugger request, a callback is stored in the adapter and then invoked when the response is received from Prepack. After this callback is called, it is no longer needed and can be deleted to save some memory Closes https://github.com/facebook/prepack/pull/1173 Differential Revision: D6379224 Pulled By: JWZ2018 fbshipit-source-id: 48e365c8f343dbd66bfafda51b804bdfc24f6d54
This commit is contained in:
parent
7b5f709904
commit
1e253b721e
@ -29,7 +29,7 @@ export class AdapterChannel {
|
||||
_ioWrapper: FileIOWrapper;
|
||||
_marshaller: MessageMarshaller;
|
||||
_queue: Queue;
|
||||
_pendingRequestCallbacks: { [number]: (DebuggerResponse) => void };
|
||||
_pendingRequestCallbacks: Map<number, (DebuggerResponse) => void>;
|
||||
_prepackWaiting: boolean;
|
||||
_eventEmitter: EventEmitter;
|
||||
_prepackProcess: child_process.ChildProcess;
|
||||
@ -68,17 +68,15 @@ export class AdapterChannel {
|
||||
}
|
||||
|
||||
_addRequestCallback(requestID: number, callback: DebuggerResponse => void) {
|
||||
invariant(!(requestID in this._pendingRequestCallbacks), "Request ID already exists in pending requests");
|
||||
this._pendingRequestCallbacks[requestID] = callback;
|
||||
invariant(!this._pendingRequestCallbacks.has(requestID), "Request ID already exists in pending requests");
|
||||
this._pendingRequestCallbacks.set(requestID, callback);
|
||||
}
|
||||
|
||||
_processRequestCallback(response: DebuggerResponse) {
|
||||
invariant(
|
||||
response.id in this._pendingRequestCallbacks,
|
||||
"Request ID does not exist in pending requests: " + response.id
|
||||
);
|
||||
let callback = this._pendingRequestCallbacks[response.id];
|
||||
let callback = this._pendingRequestCallbacks.get(response.id);
|
||||
invariant(callback !== undefined, "Request ID does not exist in pending requests: " + response.id);
|
||||
callback(response);
|
||||
this._pendingRequestCallbacks.delete(response.id);
|
||||
}
|
||||
|
||||
registerChannelEvent(event: string, listener: (response: DebuggerResponse) => void) {
|
||||
|
Loading…
Reference in New Issue
Block a user