From 92464755282db4dd120d064c6dd8f7f433fe3db8 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 8 Apr 2025 08:39:14 +0800 Subject: [PATCH] refactor: refactor codebase for improved performance and maintainability - Simplify variable initialization in `decode` method - Correct method call in `WriteString` function Signed-off-by: Bo-Yi Wu --- sse-decoder.go | 2 +- writer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sse-decoder.go b/sse-decoder.go index 8ca065b..da2c2d4 100644 --- a/sse-decoder.go +++ b/sse-decoder.go @@ -43,7 +43,7 @@ func (d *decoder) decode(r io.Reader) ([]Event, error) { } var currentEvent Event - var dataBuffer *bytes.Buffer = new(bytes.Buffer) + dataBuffer := new(bytes.Buffer) // TODO (and unit tests) // Lines must be separated by either a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair, // a single U+000A LINE FEED (LF) character, diff --git a/writer.go b/writer.go index 6f9806c..724d9d0 100644 --- a/writer.go +++ b/writer.go @@ -12,7 +12,7 @@ type stringWrapper struct { } func (w stringWrapper) WriteString(str string) (int, error) { - return w.Writer.Write([]byte(str)) + return w.Write([]byte(str)) } func checkWriter(writer io.Writer) stringWriter {