diff --git a/CHANGELOG.md b/CHANGELOG.md index a3909041d..26434313f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ When adding entries, please treat them as if they could end up in a release any Thank you! +# 0.18.26 + +* Optimises the conversion of empty smithy4s.Blob to fs2.Stream, to avoid performance degradation in Ember (see [#1609](https://github.com/disneystreaming/smithy4s/pull/1609)) + # 0.18.25 * Add A flag to allow for numerics to be decoded from JSON strings (in smithy4s-json). diff --git a/modules/http4s-kernel/src/smithy4s/http4s/kernel/package.scala b/modules/http4s-kernel/src/smithy4s/http4s/kernel/package.scala index 690bf24ad..dee0c0424 100644 --- a/modules/http4s-kernel/src/smithy4s/http4s/kernel/package.scala +++ b/modules/http4s-kernel/src/smithy4s/http4s/kernel/package.scala @@ -204,6 +204,8 @@ package object kernel { private def toStream[F[_]]( blob: Blob - ): Stream[F, Byte] = Stream.chunk(Chunk.array(blob.toArray)) + ): Stream[F, Byte] = + // Optimisation motivated by https://github.com/http4s/http4s/issues/7539 + if (blob.isEmpty) Stream.empty else Stream.chunk(Chunk.array(blob.toArray)) }