Skip to content

Commit d9659b6

Browse files
committed
Delete defunct rescheduling of timers.
In a much earlier time (e25acce), transition delays were implemented by rescheduling the step callback with a new delay; thus, d3_timer had to support finding an already-registered timer callback and changing its delay. This was not supposed to be part of the public API when d3.timer was later exposed, and is no longer needed due to the Great Transition Rewrite of D3 3.0. So, we can simplify and optimize the code by deleting this defunct feature.
1 parent 496af7e commit d9659b6

3 files changed

Lines changed: 21 additions & 35 deletions

File tree

d3.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,22 +1796,20 @@ d3 = function() {
17961796
}
17971797
d3.csv = d3_dsv(",", "text/csv");
17981798
d3.tsv = d3_dsv(" ", "text/tab-separated-values");
1799-
var d3_timer_id = 0, d3_timer_byId = {}, d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout;
1799+
var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout;
18001800
d3.timer = function(callback, delay, then) {
18011801
if (arguments.length < 3) {
18021802
if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return;
18031803
then = Date.now();
18041804
}
1805-
var time = then + delay, timer = d3_timer_byId[callback.id];
1806-
if (timer && timer.callback === callback) timer.time = time; else {
1807-
d3_timer_byId[callback.id = ++d3_timer_id] = timer = {
1808-
callback: callback,
1809-
time: time,
1810-
next: null
1811-
};
1812-
if (d3_timer_queueTail) d3_timer_queueTail.next = timer; else d3_timer_queueHead = timer;
1813-
d3_timer_queueTail = timer;
1814-
}
1805+
var time = then + delay;
1806+
var timer = {
1807+
callback: callback,
1808+
time: time,
1809+
next: null
1810+
};
1811+
if (d3_timer_queueTail) d3_timer_queueTail.next = timer; else d3_timer_queueHead = timer;
1812+
d3_timer_queueTail = timer;
18151813
if (!d3_timer_interval) {
18161814
d3_timer_timeout = clearTimeout(d3_timer_timeout);
18171815
d3_timer_interval = 1;
@@ -1848,7 +1846,6 @@ d3 = function() {
18481846
var t0, t1 = d3_timer_queueHead, time = Infinity;
18491847
while (t1) {
18501848
if (t1.flush) {
1851-
delete d3_timer_byId[t1.callback.id];
18521849
t1 = t0 ? t0.next = t1.next : d3_timer_queueHead = t1.next;
18531850
} else {
18541851
if (t1.time < time) time = t1.time;

0 commit comments

Comments
 (0)