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]>
  • Loading branch information
nfebe committed Apr 25, 2025
commit 6454cb51242428a48b9929c6a28ad9b681ef8ba0
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
Loading