diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-15 15:05:23 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-16 22:56:05 -0700 |
commit | a0e44530509d3b342b8011ac4467d957350f5ffa (patch) | |
tree | c36226f7d3c043b63a8f08f1d3b224ddf89f6844 /internal/jsonstring | |
parent | 921eeab75a87d07eaf9cec57dcdc8a3c276f291a (diff) |
Avoid io.Writer causing buffers to escape to the heap
Diffstat (limited to 'internal/jsonstring')
-rw-r--r-- | internal/jsonstring/encode_string.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/jsonstring/encode_string.go b/internal/jsonstring/encode_string.go index 1b0c68a..fec2cc0 100644 --- a/internal/jsonstring/encode_string.go +++ b/internal/jsonstring/encode_string.go @@ -10,6 +10,7 @@ import ( "unicode/utf8" "git.lukeshu.com/go/lowmemjson/internal/fastio" + "git.lukeshu.com/go/lowmemjson/internal/fastio/noescape" ) // BackslashEscapeMode is describe in the main lowmemjson package @@ -35,7 +36,7 @@ func writeStringUnicodeEscape(w io.Writer, c rune) error { alphabet[(c>>4)&0xf], alphabet[(c>>0)&0xf], } - _, err := w.Write(buf[:]) + _, err := noescape.Write(w, buf[:]) return err } @@ -58,7 +59,7 @@ func writeStringShortEscape(w io.Writer, c rune) error { panic(fmt.Errorf("should not happen: writeStringShortEscape called with invalid rune: %q", c)) } buf := [2]byte{'\\', b} - _, err := w.Write(buf[:]) + _, err := noescape.Write(w, buf[:]) return err } |