@@ -84,12 +84,7 @@ function debugModule(module, runtime) {
8484 else {
8585 recordEvent(id, v, timestep);
8686 var changed = runtime.notify(id, v, timestep);
87− if (eventsUntilSnapshot === 1) {
88− saveSnapshot();
89− eventsUntilSnapshot = EVENTS_PER_SAVE;
90− } else {
91− eventsUntilSnapshot -= 1;
92− }
87+ snapshotOnCheckpoint();
9388 if (parent.window) {
9489 parent.window.postMessage("elmNotify", window.location.origin);
9590 }
@@ -159,8 +154,13 @@ function debugModule(module, runtime) {
159154 return snapshots[snapshotEvent];
160155 }
161156
162− function saveSnapshot() {
163− snapshots.push(snapshotSignalGraph(signalGraphNodes));
157+ function snapshotOnCheckpoint() {
158+ if (eventsUntilSnapshot === 1) {
159+ snapshots.push(snapshotSignalGraph(signalGraphNodes));
160+ eventsUntilSnapshot = EVENTS_PER_SAVE;
161+ } else {
162+ eventsUntilSnapshot -= 1;
163+ }
164164 }
165165
166166 function setPaused() {
@@ -206,7 +206,7 @@ function debugModule(module, runtime) {
206206 loadRecordedEvents: loadRecordedEvents,
207207 clearSnapshots: clearSnapshots,
208208 getSnapshotAt: getSnapshotAt,
209− saveSnapshot: saveSnapshot,
209+ snapshotOnCheckpoint: snapshotOnCheckpoint,
210210 getPaused: getPaused,
211211 setPaused: setPaused,
212212 setContinue: setContinue,
@@ -319,7 +319,6 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
319319 debugModule.setPaused();
320320 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
321321 var index = getMaxSteps();
322− var eventsUntilSnapshot = EVENTS_PER_SAVE;
323322 eventCounter = 0;
324323 debugModule.tracePath.clearTraces();
325324
@@ -329,12 +328,7 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
329328 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
330329 eventCounter += 1;
331330 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
332− if (eventsUntilSnapshot === 1) {
333− debugModule.saveSnapshot();
334− eventsUntilSnapshot = EVENTS_PER_SAVE;
335− } else {
336− eventsUntilSnapshot -= 1;
337− }
331+ debugModule.snapshotOnCheckpoint();
338332 currentEventIndex += 1;
339333 }
340334 debugModule.tracePath.stopRecording();