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)
This commit is contained in:
Ankush Menat 2024-03-13 17:40:57 +05:30 committed by GitHub
parent dbde62ce40
commit bed2708bd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;