Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DecryptNotes: move the code that groups notes by account from WorkerPool to the response class #5089

Merged

Conversation

andiflabs
Copy link
Contributor

Summary

The goal of this PR is to move that chunk of code to a location where it's more easily reusable. The plan is to use the new method introduced here in PR-5058: that PR will be changed to not call WorkerPool.decryptNotes() anymore, but rather call WorkerPool.execute() to obtain the individual jobs.

Testing Plan

Unit tests

Documentation

N/A

Breaking Change

N/A

@andiflabs andiflabs requested a review from a team as a code owner June 27, 2024 22:14
accounts: ReadonlyArray<{ accountId: string }>,
): Map<string, Array<DecryptedNote | null>> {
const decryptedNotesByAccount: Array<
[accountId: string, notes: Array<DecryptedNote | null>]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.map is much slower in some cases than for..of. Not sure if this is one of those cases just checking to see if you are aware

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that a for loop can outperform .map(), but in this very specific case I'm trying to get an array out of another array, so I'd expect the performance difference to be minimal. I would be more concerned if I was doing chains of .map/.filter, because those create a new array each time, and that would be better written as a for loop (at least until Node.js gains the ability to optimize these methods). Thanks for pointing it out though.

@andiflabs andiflabs force-pushed the andrea/move-decryptnotes-response-processing-out-of-pool branch from 501ed5d to d7a9699 Compare June 27, 2024 23:44
@andiflabs andiflabs force-pushed the andrea/move-decryptnotes-response-processing-out-of-pool branch from d7a9699 to 5fdde88 Compare June 28, 2024 00:15
@andiflabs andiflabs enabled auto-merge (rebase) June 28, 2024 00:16
@andiflabs andiflabs merged commit 0f321c1 into staging Jun 28, 2024
5 checks passed
@andiflabs andiflabs deleted the andrea/move-decryptnotes-response-processing-out-of-pool branch June 28, 2024 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants