Skip to content

Commit

Permalink
Merge pull request #1677 from Vsinghal339-source/optimising-v5.6.1
Browse files Browse the repository at this point in the history
perf: Optimize SlickGrid handleSelectedRangesChanged by using Set
  • Loading branch information
ghiscoding authored Sep 13, 2024
2 parents 8d7683c + 19305b6 commit ac7e6f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/common/src/core/slickGrid.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2923,8 +2923,12 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

if (this.simpleArrayEquals(previousSelectedRows, this.selectedRows)) {
const caller = ne?.detail?.caller ?? 'click';
const newSelectedAdditions = this.getSelectedRows().filter((i) => previousSelectedRows.indexOf(i) < 0);
const newSelectedDeletions = previousSelectedRows.filter((i) => this.getSelectedRows().indexOf(i) < 0);
// Use Set for faster performance
const selectedRowsSet = new Set(this.getSelectedRows());
const previousSelectedRowsSet = new Set(previousSelectedRows);

const newSelectedAdditions = Array.from(selectedRowsSet).filter(i => !previousSelectedRowsSet.has(i));
const newSelectedDeletions = Array.from(previousSelectedRowsSet).filter(i => !selectedRowsSet.has(i));

this.triggerEvent(this.onSelectedRowsChanged, {
rows: this.getSelectedRows(),
Expand Down

0 comments on commit ac7e6f9

Please sign in to comment.