Optimized file checks via concurrent Promise.all and cleaned code.#1494
Optimized file checks via concurrent Promise.all and cleaned code.#1494tushar743-ui wants to merge 1 commit into
Conversation
Signed-off-by: tushar743-ui <tusharpatle743@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the performance and clarity of getCurationSketches() by parallelizing cached sketch-file existence checks and simplifying the resulting filtering/return flow.
Changes:
- Normalized formatting for the
priorityIdslist. - Replaced sequential
await exists(...)checks with concurrentPromise.all(...)checks. - Simplified sketch availability filtering and returned the filtered array directly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @tushar743-ui, thank you for this PR. I looked into it and wanted to share some thoughts. Looking at the live site at Since no issue was opened for this, it is hard to know what specific problem is being solved. The p5.js website has a contributing process where changes like this should start with an issue. I may be missing context, so opening an issue would help the community weigh in on whether this optimisation is needed and the best approach to take. Please check the README for more on the contributing process. |
Formatting: Normalized inconsistent spacing .
Parallelized existence checks: Replaced the sequential for...of loop awaiting exists() one sketch at a time with Promise.all(allSketches.map(...)), so all file-existence checks run concurrently instead of blocking one-by-one.
Simplified return: Filtered allSketches directly against the resolved existence results instead of building availableSketches via push-in-a-loop, then dropped the pointless return [...availableSketches] spread in favor of returning the array directly.
Why: the original loop serialized an I/O-bound check (exists) per sketch, which is unnecessarily slow when the list grows; batching with Promise.all cuts wall-clock time while keeping identical output.