Skip to content

Commit

Permalink
sheet: Computations<V> reverts to array
Browse files Browse the repository at this point in the history
  • Loading branch information
hbbio committed Apr 2, 2024
1 parent 090de07 commit 11f7b83
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import { dispatch, dispatchPromiseOrValueArray } from "./promise";
import { SheetProxy } from "./proxy";
import type { AnyCellArray } from "./types";

type Computations<V> = Record<
number,
Pending<V | Canceled, true> | CellResult<V | Canceled, true>
>;
type Computations<V> = (
| Pending<V | Canceled, true>
| CellResult<V | Canceled, true>
)[];
type IterationResult<V> = {
computations: Computations<V>;
updated: Set<number>;
Expand Down Expand Up @@ -506,7 +506,7 @@ export class Sheet {
);
};

const computations: Computations<V> = {};
const computations: Computations<V> = [];
const release = this.working.startNewComputation();
for (const id of roots) {
computations[id] = dispatch(
Expand Down Expand Up @@ -617,7 +617,7 @@ export class Sheet {
// Form now on, we need updatable pointers to be up-to-date to continue
const newComputations = this.computeUpdatable(toBeRecomputed, computations);
const borderComputation = dispatchPromiseOrValueArray(
Object.values(newComputations),
newComputations,
// wait for all new computations to be over before proceeding to the next step
(newComputations) => {
// finding all canceled computations
Expand Down Expand Up @@ -649,7 +649,7 @@ export class Sheet {
borderComputation,
({ computationsOfBorder, nextIteration }) => {
return dispatchPromiseOrValueArray(
Object.values(computationsOfBorder),
computationsOfBorder,
(computationsOfBorder) => {
//checking for canceled computations
this.registerCancelAndDone(
Expand Down Expand Up @@ -826,7 +826,7 @@ export class Sheet {
): Computations<V> {
const order = toBeRecomputed.slice(); // slice copies the array
let currentCellId: number | undefined;
const newComputations = {};
const newComputations = [];

// biome-ignore lint/suspicious/noAssignInExpressions: shorter, still explicit
while ((currentCellId = order.pop()) !== undefined) {
Expand Down

0 comments on commit 11f7b83

Please sign in to comment.