Skip to content

Commit b71fb4e

Browse files
author
Philip Guo
committed
slight code simplification
1 parent 91118e3 commit b71fb4e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

PyTutorGAE/js/edu-python.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ function precomputeCurTraceLayouts() {
308308

309309

310310
function recurseIntoObject(id, curRow, newRow) {
311+
console.log('recurseIntoObject', id, curRow, newRow);
312+
311313
// heuristic for laying out 1-D linked data structures: check for enclosing elements that are
312314
// structurally identical and then lay them out as siblings in the same "row"
313315
var heapObj = curEntry.heap[id];
@@ -320,9 +322,7 @@ function precomputeCurTraceLayouts() {
320322
if (!isPrimitiveType(child)) {
321323
var childID = getRefID(child);
322324
if (structurallyEquivalent(heapObj, curEntry.heap[childID])) {
323-
if (!idsAlreadyLaidOut.has(childID)) { // TODO: awkward guard location
324-
updateCurLayout(childID, curRow, newRow);
325-
}
325+
updateCurLayout(childID, curRow, newRow);
326326
}
327327
}
328328
});
@@ -335,9 +335,7 @@ function precomputeCurTraceLayouts() {
335335
if (!isPrimitiveType(dictVal)) {
336336
var childID = getRefID(dictVal);
337337
if (structurallyEquivalent(heapObj, curEntry.heap[childID])) {
338-
if (!idsAlreadyLaidOut.has(childID)) { // TODO: awkward guard location
339-
updateCurLayout(childID, curRow, newRow);
340-
}
338+
updateCurLayout(childID, curRow, newRow);
341339
}
342340
}
343341
});
@@ -353,9 +351,7 @@ function precomputeCurTraceLayouts() {
353351
if (!isPrimitiveType(instVal)) {
354352
var childID = getRefID(instVal);
355353
if (structurallyEquivalent(heapObj, curEntry.heap[childID])) {
356-
if (!idsAlreadyLaidOut.has(childID)) { // TODO: awkward guard location
357-
updateCurLayout(childID, curRow, newRow);
358-
}
354+
updateCurLayout(childID, curRow, newRow);
359355
}
360356
}
361357
});
@@ -371,9 +367,11 @@ function precomputeCurTraceLayouts() {
371367
// newRow - a new row that might be spliced into curRow or appended
372368
// as a new row in curLayout
373369
function updateCurLayout(id, curRow, newRow) {
374-
var curLayoutLoc = curLayoutIndexOf(id);
370+
if (idsAlreadyLaidOut.has(id)) {
371+
return; // PUNT!
372+
}
375373

376-
console.log('updateCurLayout', id, curRow, newRow, curLayoutLoc);
374+
var curLayoutLoc = curLayoutIndexOf(id);
377375

378376
var alreadyLaidOut = idsAlreadyLaidOut.has(id);
379377
idsAlreadyLaidOut.set(id, 1); // unconditionally set now

0 commit comments

Comments
 (0)