From 1745a6e62bb920f4df4c1c52222cafe8fd578977 Mon Sep 17 00:00:00 2001 From: brrichards Date: Sat, 6 Jun 2026 00:03:36 +0000 Subject: [PATCH 1/2] small perf optimization for createTableTree --- .../src/test/tablePerformanceTestUtilities.ts | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts b/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts index ad6d7baa1aee..444845ddc9b1 100644 --- a/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts +++ b/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts @@ -118,28 +118,19 @@ export function createTableTree({ tableSize, initialCellValue }: TableTreeOption const columns = Array.from({ length: tableSize }, () => new Column({})); table.insertColumns({ index: 0, columns }); - const rows = Array.from( - { length: tableSize }, - () => - new Row({ - cells: {}, - }), - ); - table.insertRows({ index: 0, rows }); - - if (initialCellValue !== undefined) { - for (const row of table.rows) { - for (const column of table.columns) { - table.setCell({ - key: { - column, - row, - }, - cell: initialCellValue, - }); + // Pre populate each row's cells at construction time so the entire dense table is initialized + // by a single `insertRows` op. O(n) + const columnIds = table.columns.map((column) => column.id); + const rows = Array.from({ length: tableSize }, () => { + const cells: Record = {}; + if (initialCellValue !== undefined) { + for (const columnId of columnIds) { + cells[columnId] = initialCellValue; } } - } + return new Row({ cells }); + }); + table.insertRows({ index: 0, rows }); // Configure event listeners const cleanUpEventHandler = Tree.on(table, "treeChanged", () => {}); From 8aa328d1fd9bfc0a8a75333a601e488c78f81f66 Mon Sep 17 00:00:00 2001 From: brrichards Date: Sat, 6 Jun 2026 00:04:54 +0000 Subject: [PATCH 2/2] comment update --- packages/dds/tree/src/test/tablePerformanceTestUtilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts b/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts index 444845ddc9b1..1fe167f384ee 100644 --- a/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts +++ b/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts @@ -119,7 +119,7 @@ export function createTableTree({ tableSize, initialCellValue }: TableTreeOption table.insertColumns({ index: 0, columns }); // Pre populate each row's cells at construction time so the entire dense table is initialized - // by a single `insertRows` op. O(n) + // by a single `insertRows` op. const columnIds = table.columns.map((column) => column.id); const rows = Array.from({ length: tableSize }, () => { const cells: Record = {};