Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
perf(files_sharing): Change sharing filtering from O(3n) to O(n)
Replaced multiple Array.filter() calls with a single loop to improve performance.

This avoids redundant iterations over the shares array and categorizes them more efficiently.

Signed-off-by: nfebe <[email protected]>

Signed-off-by: nextcloud-command <[email protected]>
  • Loading branch information
nfebe committed May 6, 2025
commit d1b91c47a3609a87c9387f1bf0971d693a351d5a
12 changes: 9 additions & 3 deletions apps/files_sharing/src/views/SharingTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,15 @@ export default {
],
)

this.linkShares = shares.filter(share => [ShareType.Link, ShareType.Email].includes(share.type))
this.shares = shares.filter(share => ![ShareType.Link, ShareType.Email, ShareType.Remote, ShareType.RemoteGroup].includes(share.type))
this.externalShares = shares.filter(share => [ShareType.Remote, ShareType.RemoteGroup].includes(share.type))
for (const share of shares) {
if ([ShareType.Link, ShareType.Email].includes(share.type)) {
this.linkShares.push(share)
} else if ([ShareType.Remote, ShareType.RemoteGroup].includes(share.type)) {
this.externalShares.push(share)
} else {
this.shares.push(share)
}
}

logger.debug(`Processed ${this.linkShares.length} link share(s)`)
logger.debug(`Processed ${this.shares.length} share(s)`)
Expand Down