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

perf(ecau): refactor sync generators to prevent babel regenerator #401

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

ROpdebee
Copy link
Owner

Fixes #399.

@codecov
Copy link

codecov bot commented Jan 27, 2022

Codecov Report

Merging #401 (49e3ce5) into main (19ad96d) will decrease coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##              main     #401      +/-   ##
===========================================
- Coverage   100.00%   99.90%   -0.10%     
===========================================
  Files           44       44              
  Lines          995     1002       +7     
  Branches       167      168       +1     
===========================================
+ Hits           995     1001       +6     
- Partials         0        1       +1     
Impacted Files Coverage Δ
src/lib/util/array.ts 100.00% <100.00%> (ø)
src/mb_enhanced_cover_art_uploads/fetch.ts 100.00% <100.00%> (ø)
src/mb_enhanced_cover_art_uploads/maximise.ts 97.77% <0.00%> (-2.23%) ⬇️
src/lib/util/urls.ts 100.00% <0.00%> (ø)
.../mb_enhanced_cover_art_uploads/providers/amazon.ts 100.00% <0.00%> (ø)
...mb_enhanced_cover_art_uploads/providers/discogs.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19ad96d...49e3ce5. Read the comment docs.

Copy link
Collaborator

@kellnerd kellnerd left a comment

Choose a reason for hiding this comment

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

The alternative would be to use Array.forEach() which also provides the index to its callback function. That would be doable for our current use case, but it's not always feasible to use a callback function instead of an inline loop.

@ROpdebee
Copy link
Owner Author

ROpdebee commented Jan 27, 2022

That would be doable for our current use case

It wouldn't preserve the current semantics, since there's async stuff going on in the loop body. While we could use Array.map with Promise.all, that would lead to multiple images being fetched in parallel and the log messages showing up out-of-order. That could still be acceptable though. Since we're trying to prevent duplicate images, we can't fetch them in parallel as that could lead to race conditions.

Speaking of Array.map, why am I not just doing return array.map((el, idx) => [el, idx])? 🤔

@ROpdebee ROpdebee force-pushed the ecau-no-regenerator branch from 43c3872 to 49e3ce5 Compare January 27, 2022 14:17
@ROpdebee ROpdebee requested a review from kellnerd January 27, 2022 14:17
Copy link
Collaborator

@kellnerd kellnerd left a comment

Choose a reason for hiding this comment

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

You are right, I had missed the await keyword.

@ROpdebee ROpdebee merged commit c38857d into main Jan 27, 2022
@ROpdebee ROpdebee deleted the ecau-no-regenerator branch January 27, 2022 15:29
github-actions bot added a commit that referenced this pull request Jan 27, 2022
perf(ecau): refactor sync generators to prevent babel regenerator (#401)
@github-actions
Copy link

🚀 Released 1 new userscript version(s):

  • mb_enhanced_cover_art_uploads 2022.1.27.4 in 7f0fdf6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ECAU 2021.1.26.2 added an unwelcome guest
2 participants