jrudolph commented on code in PR #311:
URL:
https://github.com/apache/incubator-pekko-http/pull/311#discussion_r1311584528
##########
http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/MessageToFrameRenderer.scala:
##########
@@ -35,20 +34,10 @@ private[http] object MessageToFrameRenderer {
Source.single(FrameEvent.fullFrame(opcode, None, data, fin = true))
def streamedFrames[M](opcode: Opcode, data: Source[ByteString, M]):
Source[FrameStart, Any] =
- data.via(StreamUtils.statefulMap(() => {
- var isFirst = true
-
- { data =>
- val frameOpcode =
- if (isFirst) {
- isFirst = false
- opcode
- } else Opcode.Continuation
-
- FrameEvent.fullFrame(frameOpcode, None, data, fin = false)
- }
- })) ++
- Source.single(FrameEvent.emptyLastContinuationFrame)
+ data.statefulMap(() => true)((isFirst, data) => {
+ val frameOpcode = if (isFirst) opcode else Opcode.Continuation
+ (false, FrameEvent.fullFrame(frameOpcode, None, data, fin = false))
Review Comment:
How much more boxing and allocations will that produce?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]