Skip to content

Commit

Permalink
Merge pull request #3144 from armanbilge/pr/signal-get-and-discrete-u…
Browse files Browse the repository at this point in the history
…pdates-optimizations

Microptimize `Signal#getAndDiscreteUpdates`
  • Loading branch information
diesalbla authored Feb 15, 2023
2 parents 1531919 + 8953891 commit 0dafa1f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/shared/src/main/scala/fs2/concurrent/Signal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ object SignallingRef {
def cleanup(id: Long): F[Unit] =
state.update(s => s.copy(listeners = s.listeners - id))

Resource.eval(state.get).map { s =>
Resource.eval(state.get.map { s =>
(s.value, Stream.bracket(newId)(cleanup).flatMap(go(_, s.lastUpdate)))
}
})
}

def set(a: A): F[Unit] = update(_ => a)
Expand Down Expand Up @@ -565,14 +565,14 @@ object SignallingMapRef {
}
}

Resource.eval(state.get).map { state =>
Resource.eval(state.get.map { state =>
(
state.keys.get(k).flatMap(_.value),
Stream
.bracket(newId)(cleanup)
.flatMap(go(_, state.keys.get(k).fold(-1L)(_.lastUpdate)))
)
}
})
}

def set(v: Option[V]): F[Unit] = update(_ => v)
Expand Down

0 comments on commit 0dafa1f

Please sign in to comment.