Skip to content

Commit

Permalink
Remove checking for negative array size
Browse files Browse the repository at this point in the history
Consolidate two subsequent `.flatMap`s into one.
  • Loading branch information
Leif Warner committed Nov 13, 2024
1 parent 96f4b5a commit b7d78a3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions fs2-aws-s3/src/main/scala/fs2/aws/s3/S3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,11 @@ object S3 {
.last
.flatMap {
case Some(resp) =>
Pull.pure {
val bs = resp.asByteArrayUnsafe
Option.when(bs.length >= 0)(Chunk.array(bs))
}
val chunk = Chunk.array(resp.asByteArrayUnsafe)
Pull.output(chunk) >> (if (chunk.size < chunkSizeBytes) Pull.done else go(offset + chunk.size))
case None =>
Pull.pure(none)
}
.flatMap {
case Some(o) =>
if (o.size < chunkSizeBytes) Pull.output(o)
else Pull.output(o) >> go(offset + o.size)
case None => Pull.done
Pull.done
}

go(0).stream
}

Expand Down

0 comments on commit b7d78a3

Please sign in to comment.