Skip to content

Commit

Permalink
perf: rendering large data (#197)
Browse files Browse the repository at this point in the history
visibleRowIndices.includes is major culprit in rendering data table.
This is because for every row it does this computation, so instead of
O(N) operation it becomes O(N^2)
  • Loading branch information
ankush authored Mar 13, 2024
1 parent dbde62c commit bed2708
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/body-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export default class BodyRenderer {
return;
}

// Create a temporary set for faster lookups.
// We can't change this.visibleRowIndices as it would be breaking for users.
let visibleRowIndicesSet = new Set(this.visibleRowIndices);
const rowViewOrder = this.datamanager.rowViewOrder.map(index => {
if (this.visibleRowIndices.includes(index)) {
if (visibleRowIndicesSet.has(index)) {
return index;
}
return null;
Expand Down

0 comments on commit bed2708

Please sign in to comment.