Permalink
Browse files

Stop using Map in JSTimers

Reviewed By: fromcelticpark

Differential Revision: D5292912

fbshipit-source-id: a14552b895d586cf24627cc457069d9909b2ecc2
  • Loading branch information...
javache authored and facebook-github-bot committed Jun 22, 2017
1 parent 94d9f00 commit e9f657f2bd1679887bbdf69b1093887547cc3b2b
Showing with 7 additions and 7 deletions.
  1. +6 −6 Libraries/Core/Timers/JSTimers.js
  2. +1 −1 Libraries/Core/Timers/JSTimersExecution.js
@@ -145,10 +145,10 @@ const JSTimers = {
const id = _allocateCallback(
timeout != null ?
deadline => {
const timeoutId = JSTimersExecution.requestIdleCallbackTimeouts.get(id);
const timeoutId = JSTimersExecution.requestIdleCallbackTimeouts[id];
if (timeoutId) {
JSTimers.clearTimeout(timeoutId);
JSTimersExecution.requestIdleCallbackTimeouts.delete(id);
JSTimersExecution.requestIdleCallbackTimeouts[id];

This comment has been minimized.

Show comment
Hide comment
@fabriziomoscon

fabriziomoscon Sep 8, 2017

@javache If you want a 1 to 1 mapping from the old file this should have been changed to delete ... [id]

@fabriziomoscon

fabriziomoscon Sep 8, 2017

@javache If you want a 1 to 1 mapping from the old file this should have been changed to delete ... [id]

}
return func(deadline);
} :
@@ -164,12 +164,12 @@ const JSTimers = {
JSTimersExecution.requestIdleCallbacks.splice(index, 1);
JSTimersExecution.callTimer(id, performanceNow(), true);
}
JSTimersExecution.requestIdleCallbackTimeouts.delete(id);
delete JSTimersExecution.requestIdleCallbackTimeouts[id];
if (JSTimersExecution.requestIdleCallbacks.length === 0) {
Timing.setSendIdleEvents(false);
}
}, timeout);
JSTimersExecution.requestIdleCallbackTimeouts.set(id, timeoutId);
JSTimersExecution.requestIdleCallbackTimeouts[id] = timeoutId;
}
return id;
},
@@ -181,10 +181,10 @@ const JSTimers = {
JSTimersExecution.requestIdleCallbacks.splice(index, 1);
}
const timeoutId = JSTimersExecution.requestIdleCallbackTimeouts.get(timerID);
const timeoutId = JSTimersExecution.requestIdleCallbackTimeouts[timerID];
if (timeoutId) {
JSTimers.clearTimeout(timeoutId);
JSTimersExecution.requestIdleCallbackTimeouts.delete(timerID);
delete JSTimersExecution.requestIdleCallbackTimeouts[timerID];
}
if (JSTimersExecution.requestIdleCallbacks.length === 0) {
@@ -45,7 +45,7 @@ const JSTimersExecution = {
timerIDs: ([] : Array<?number>),
immediates: [],
requestIdleCallbacks: [],
requestIdleCallbackTimeouts: (new Map() : Map<number, number>),
requestIdleCallbackTimeouts: ({} : {[number]: number}),
identifiers: ([] : Array<null | {methodName: string}>),
errors: (null : ?Array<Error>),

1 comment on commit e9f657f

@esprehn

This comment has been minimized.

Show comment
Hide comment
@esprehn

esprehn Aug 9, 2017

Contributor

Is there a backstory for this change? Very curious why the Map wasn't working out. :)

Contributor

esprehn commented on e9f657f Aug 9, 2017

Is there a backstory for this change? Very curious why the Map wasn't working out. :)

Please sign in to comment.