Skip to content

Commit b7a2fa1

Browse files
committed
[middleware] DidSetRow optimization
1 parent cb24e52 commit b7a2fa1

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎src/store/index.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,13 +1755,16 @@ export const createStore: typeof createStoreDecl = (): Store => {
17551755
? objDel(oldRow, cellId)
17561756
: (oldRow[cellId] = oldCell),
17571757
);
1758-
const finalRow = middleware[14]!(tableId, rowId, oldRow, newRow);
1759-
if (!objIsEqual(finalRow, newRow)) {
1760-
if (objIsEmpty(finalRow)) {
1761-
delRow(tableId, rowId);
1762-
} else {
1763-
setRow(tableId, rowId, finalRow);
1764-
}
1758+
const didSetRow = middleware[14]!(tableId, rowId, oldRow, newRow);
1759+
if (!objIsEqual(didSetRow, newRow)) {
1760+
const setOrDelRow: {[id: string]: CellOrUndefined} = objMap(
1761+
newRow,
1762+
() => undefined,
1763+
);
1764+
objMap(didSetRow, (cell, cellId) => (setOrDelRow[cellId] = cell));
1765+
objMap(setOrDelRow, (cell, cellId) =>
1766+
setOrDelCell(tableId, rowId, cellId, cell, true),
1767+
);
17651768
}
17661769
}
17671770
}),

0 commit comments

Comments
 (0)