1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Desktop,Mobile: Fixes #11065: Improve performance when there are many selected items (#11067)

This commit is contained in:
Henry Heino
2024-09-21 04:53:16 -07:00
committed by GitHub
parent 5beb80bf61
commit 0965c6d257
6 changed files with 42 additions and 5 deletions

View File

@@ -169,11 +169,15 @@ class BaseModel {
public static modelsByIds<T extends BaseItemEntity>(items: T[], ids: string[]): T[] {
const output = [];
for (let i = 0; i < items.length; i++) {
if (ids.indexOf(items[i].id) >= 0) {
output.push(items[i]);
// Prefer a `Set` to using `ids.includes` -- this gives a better running time.
const idSet = new Set(ids);
for (const item of items) {
if (idSet.has(item.id)) {
output.push(item);
}
}
return output;
}