Apart from simplification this transformation is likely to bring faster code which consumes less memory.

Comment From: jhoeller

This looks entirely valid, worth applying to 5.2.7 from my perspective. Maybe an opportunity to revisit related code for efficient StringBuilder usage?

Comment From: jhoeller

I've taken this a bit further by enforcing StringBuilder exposure throughout the encode/decode methods in both ServerSentEventHttpMessageReader and ServerSentEventHttpMessageWriter, in particular also for the event content, not just for the comment part. Thanks for raising this!