Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@guizmaii
Copy link
Member

@guizmaii guizmaii commented Feb 6, 2025

Similar changes to those made in this PR #9383

The optimisations are less significant than in #9383 (No Result trick optimisation for example) as the code isn't really more optimisable, I think

@guizmaii guizmaii marked this pull request as draft February 6, 2025 12:49
@guizmaii guizmaii force-pushed the simplify_ZChannel_mapOutZIOPar branch 2 times, most recently from c2d5245 to 4e1e8b0 Compare February 6, 2025 12:50
@guizmaii guizmaii self-assigned this Feb 6, 2025
@guizmaii guizmaii force-pushed the simplify_ZChannel_mapOutZIOPar branch 2 times, most recently from 3f48da0 to 577273f Compare February 6, 2025 21:53
similar change to those made in this PR #9383
@guizmaii guizmaii force-pushed the simplify_ZChannel_mapOutZIOPar branch from 577273f to c6b8ca4 Compare February 6, 2025 21:55
@guizmaii guizmaii marked this pull request as ready for review February 6, 2025 22:08
Copy link
Member

@regiskuckaertz regiskuckaertz left a comment

Choose a reason for hiding this comment

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

Lgtm👌

@guizmaii guizmaii merged commit eb621a7 into series/2.x Feb 7, 2025
18 checks passed
@guizmaii guizmaii deleted the simplify_ZChannel_mapOutZIOPar branch February 7, 2025 22:03
val permits = Semaphore.unsafe.make(n0)(Unsafe)
val failureRef = Ref.unsafe.make[Cause[OutErr1]](Cause.empty)(Unsafe)

val setFinalizer: UIO[Unit] =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this needs to be a val. it won't save you any performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just to follow the same code pattern used in #9383

I think this val will be inlined at runtime, so yeah, there are no changes in terms of performances. It's esthetic


permits
.withPermit(
latch.succeed(()) *>
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can unsafely complete the promise with Exit.unit to avoid an allocation here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! See #9571

f(outElem)
.catchAllCause(cause =>
failureRef.update(_ && cause).unless(cause.isInterruptedOnly) *>
errorSignal.succeed(()) *>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Exit.unit here as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! See #9571

guizmaii added a commit that referenced this pull request Feb 10, 2025
…when possible

Idea comes from @hearnadam's review in this PR: #9556
guizmaii added a commit that referenced this pull request Feb 10, 2025
…when possible

Idea comes from @hearnadam's review in this PR: #9556
guizmaii added a commit that referenced this pull request Feb 10, 2025
…when possible

Idea comes from @hearnadam's review in this PR: #9556
guizmaii added a commit that referenced this pull request Feb 10, 2025
…when possible

Idea comes from @hearnadam's review in this PR: #9556
guizmaii added a commit that referenced this pull request Feb 10, 2025
…when possible

Idea comes from @hearnadam's review in this PR: #9556
guizmaii added a commit that referenced this pull request Feb 10, 2025
…when possible (#9571)

* Add internal `Promise#succeedUnit` method to avoid `Exit` allocation when possible

Idea comes from @hearnadam's review in this PR: #9556

* fmt

* Review: Use `whenZIODiscard` when possible
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.

4 participants