From edd3beedb404412428a72ca077d53d1f8c550607 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 6 Apr 2025 10:14:57 +0800 Subject: bare: Zero-copy []byte and string conversions --- forged/internal/bare/writer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'forged/internal/bare/writer.go') diff --git a/forged/internal/bare/writer.go b/forged/internal/bare/writer.go index 03cbf96..bada045 100644 --- a/forged/internal/bare/writer.go +++ b/forged/internal/bare/writer.go @@ -8,6 +8,8 @@ import ( "fmt" "io" "math" + + "go.lindenii.runxiyu.org/forge/forged/internal/misc" ) // A Writer for BARE primitive types. @@ -85,7 +87,7 @@ func (w *Writer) WriteBool(b bool) error { } func (w *Writer) WriteString(str string) error { - return w.WriteData([]byte(str)) + return w.WriteData(misc.StringToBytes(str)) } // Writes a fixed amount of arbitrary data, defined by the length of the slice. -- cgit v1.2.3