Skip to content

Commit bed2708

Browse files
authored
perf: rendering large data (#197)
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)
1 parent dbde62c commit bed2708

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/body-renderer.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ export default class BodyRenderer {
2121
return;
2222
}
2323

24+
// Create a temporary set for faster lookups.
25+
// We can't change this.visibleRowIndices as it would be breaking for users.
26+
let visibleRowIndicesSet = new Set(this.visibleRowIndices);
2427
const rowViewOrder = this.datamanager.rowViewOrder.map(index => {
25-
if (this.visibleRowIndices.includes(index)) {
28+
if (visibleRowIndicesSet.has(index)) {
2629
return index;
2730
}
2831
return null;

0 commit comments

Comments
 (0)