Skip to content

Commit 5c766b9

Browse files
committed
Make StreamSubscription.run a def (again)
1 parent 3f2cab8 commit 5c766b9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/shared/src/main/scala/fs2/interop/flow/StreamSubscription.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ private[flow] final class StreamSubscription[F[_], A] private (
5858
sub.onComplete()
5959
}
6060

61-
val run: F[Unit] = {
61+
// This is a def rather than a val, because it is only used once.
62+
// And having fields increase the instantiation cost and delay garbage collection.
63+
def run: F[Unit] = {
6264
val subscriptionPipe: Pipe[F, A, A] = in => {
6365
def go(s: Stream[F, A]): Pull[F, A, Unit] =
6466
Pull.eval(F.delay(requests.get())).flatMap { n =>

0 commit comments

Comments
 (0)