Skip to content

Commit

Permalink
Avoid double evaluation of by-name parameter in Stream.fromChunk cons…
Browse files Browse the repository at this point in the history
…tructor (zio#6757)
  • Loading branch information
swachter authored May 2, 2022
1 parent 5e56f0e commit 39322c7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions streams/shared/src/main/scala/zio/stream/ZStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3764,8 +3764,16 @@ object ZStream extends ZStreamPlatformSpecificConstructors {
for {
doneRef <- Ref.make(false).toManaged_
pull = doneRef.modify { done =>
if (done || c.isEmpty) Pull.end -> true
else ZIO.succeedNow(c) -> true
if (done) {
Pull.end -> true
} else {
val c0 = c
if (c0.isEmpty) {
Pull.end -> true
} else {
ZIO.succeedNow(c0) -> true
}
}
}.flatten
} yield pull
}
Expand Down

0 comments on commit 39322c7

Please sign in to comment.