Skip to content

Commit

Permalink
Merge pull request #6917 from Agoric/vref-status-use-map
Browse files Browse the repository at this point in the history
fix(liveslots): use Map for vrefStatus, not object
  • Loading branch information
mergify[bot] authored Feb 4, 2023
2 parents caf0bf0 + 1456e2a commit 87023e8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/swingset-liveslots/src/virtualReferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,20 @@ export function makeVirtualReferenceManager(
// to which appear in the after state must look only at the presence or
// absence of individual elements from the slots arrays and pay no attention
// to the organization of the slots arrays themselves.
const vrefStatus = {};
const vrefStatus = new Map();
for (const vref of beforeSlots) {
vrefStatus[vref] = 'drop';
vrefStatus.set(vref, 'drop');
}
for (const vref of afterSlots) {
if (vrefStatus[vref] === 'drop') {
vrefStatus[vref] = 'keep';
} else if (!vrefStatus[vref]) {
vrefStatus[vref] = 'add';
if (vrefStatus.get(vref) === 'drop') {
vrefStatus.set(vref, 'keep');
} else if (!vrefStatus.has(vref)) {
vrefStatus.set(vref, 'add');
}
}
for (const [vref, status] of Object.entries(vrefStatus)) {
switch (status) {
const keys = [...vrefStatus.keys()].sort();
for (const vref of keys) {
switch (vrefStatus.get(vref)) {
case 'add':
addReachableVref(vref);
break;
Expand Down

0 comments on commit 87023e8

Please sign in to comment.