8000 Optimize `FiberRef#locallyScopedWith` by guizmaii · Pull Request #9483 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Optimize FiberRef#locallyScopedWith #9483

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

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

guizmaii
Copy link
Member

Removing one get call

@@ -185,7 +185,7 @@ trait FiberRef[A] extends Serializable { self =>
* value when the scope is closed.
*/
final def locallyScopedWith(f: A => A)(implicit trace: Trace): ZIO[Scope, Nothing, Unit] =
getWith(a => locallyScoped(f(a))(trace))
ZIO.acquireRelease(get.flatMap(a => set(f(a)).as(a)))(set).unit
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we use getAndSet 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.

Hum no but we can use modify. I'll update the implementation

Removing one `get` call
@guizmaii guizmaii force-pushed the o 8000 pt_FiberRef_locallyScopedWith branch from e9710d6 to fda2d2e Compare January 20, 2025 07:48
@kyri-petrou kyri-petrou merged commit 4a9aafa into series/2.x Jan 20, 2025
18 checks passed
@kyri-petrou kyri-petrou deleted the opt_FiberRef_locallyScopedWith branch January 20, 2025 15:30
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
0