Skip to content

Commit 092f9b2

Browse files
authored
safe to create ByteString from array with no-copy (#821)
* safe to create ByteString from array with no-copy * another place where we know that the array is private in scope
1 parent dff2840 commit 092f9b2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameEventRenderer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ private[http] final class FrameEventRenderer extends GraphStage[FlowShape[FrameE
129129
data(maskOffset + 3) = ((mask & 0x000000FF) >> 0).toByte
130130
}
131131

132-
ByteString(data)
132+
ByteString.fromArrayUnsafe(data)
133133
}
134134
}

http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToEntityMarshallers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trait PredefinedToEntityMarshallers extends MultipartMarshallers {
4747
val byteBuffer = contentType.charset.nioCharset.encode(charBuffer)
4848
val array = new Array[Byte](byteBuffer.remaining())
4949
byteBuffer.get(array)
50-
HttpEntity(contentType, array)
50+
HttpEntity(contentType, ByteString.fromArrayUnsafe(array))
5151
} else HttpEntity.Empty
5252

5353
implicit val DoneMarshaller: ToEntityMarshaller[pekko.Done] =

0 commit comments

Comments
 (0)