Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Improve parallelMap #80

Merged
merged 3 commits into from
Apr 16, 2020
Merged

Improve parallelMap #80

merged 3 commits into from
Apr 16, 2020

Conversation

kean
Copy link
Contributor

@kean kean commented Apr 11, 2020

  • Remove withoutActuallyEscaping, concurrentPerform already accepts a nonescaping closure
  • Avoid sorting results as it might become quite expensive with large N

@kean kean changed the title Improve parallelMap Improve parallelMap Apr 11, 2020
@mattt
Copy link
Contributor

mattt commented Apr 16, 2020

Thanks for this patch, @kean!

You're totally right about withoutActuallyEscaping being unnecessary here. I was less confident about the correctness of preallocating a fixed-size collection to collect the transformed results (hence my original approach), but after re-reading the Swift Type Layout documentation and checking a few assumptions with MemoryLayout in a Playground, I can't think of any cases where this wouldn't work.

I don't think we need a Changelog entry for this PR since this is an implementation detail, so I'll merge this now.

@mattt mattt merged commit ac7e049 into SwiftDocOrg:master Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants