From 2b9473f5e8816eeea76b2fdada184532be00d3a2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 7 Feb 2023 12:18:29 -0700 Subject: internal: Split in to sub-packages --- encode_string.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'encode_string.go') diff --git a/encode_string.go b/encode_string.go index 12f934e..a5d6633 100644 --- a/encode_string.go +++ b/encode_string.go @@ -8,17 +8,19 @@ import ( "io" "unicode/utf8" - "git.lukeshu.com/go/lowmemjson/internal" + "git.lukeshu.com/go/lowmemjson/internal/fastio" + "git.lukeshu.com/go/lowmemjson/internal/jsonparse" + "git.lukeshu.com/go/lowmemjson/internal/jsontest" ) func writeStringUnicodeEscape(w io.Writer, c rune) (int, error) { buf := [6]byte{ '\\', 'u', - internal.Hex[(c>>12)&0xf], - internal.Hex[(c>>8)&0xf], - internal.Hex[(c>>4)&0xf], - internal.Hex[(c>>0)&0xf], + jsonparse.Hex[(c>>12)&0xf], + jsonparse.Hex[(c>>8)&0xf], + jsonparse.Hex[(c>>4)&0xf], + jsonparse.Hex[(c>>0)&0xf], } return w.Write(buf[:]) } @@ -45,7 +47,7 @@ func writeStringShortEscape(w io.Writer, c rune) (int, error) { return w.Write(buf[:]) } -func writeStringChar(w internal.AllWriter, c rune, wasEscaped BackslashEscapeMode, escaper BackslashEscaper) (int, error) { +func writeStringChar(w fastio.AllWriter, c rune, wasEscaped BackslashEscapeMode, escaper BackslashEscaper) (int, error) { if escaper == nil { escaper = EscapeDefault } @@ -83,7 +85,7 @@ func writeStringChar(w internal.AllWriter, c rune, wasEscaped BackslashEscapeMod } } -func encodeStringFromString(w internal.AllWriter, escaper BackslashEscaper, str string) error { +func encodeStringFromString(w fastio.AllWriter, escaper BackslashEscaper, str string) error { if err := w.WriteByte('"'); err != nil { return err } @@ -98,7 +100,7 @@ func encodeStringFromString(w internal.AllWriter, escaper BackslashEscaper, str return nil } -func encodeStringFromBytes(w internal.AllWriter, escaper BackslashEscaper, str []byte) error { +func encodeStringFromBytes(w fastio.AllWriter, escaper BackslashEscaper, str []byte) error { if err := w.WriteByte('"'); err != nil { return err } @@ -116,13 +118,13 @@ func encodeStringFromBytes(w internal.AllWriter, escaper BackslashEscaper, str [ } func init() { - internal.EncodeStringFromString = func(w io.Writer, s string) { - if err := encodeStringFromString(internal.NewAllWriter(w), nil, s); err != nil { + jsontest.EncodeStringFromString = func(w io.Writer, s string) { + if err := encodeStringFromString(fastio.NewAllWriter(w), nil, s); err != nil { panic(err) } } - internal.EncodeStringFromBytes = func(w io.Writer, s []byte) { - if err := encodeStringFromBytes(internal.NewAllWriter(w), nil, s); err != nil { + jsontest.EncodeStringFromBytes = func(w io.Writer, s []byte) { + if err := encodeStringFromBytes(fastio.NewAllWriter(w), nil, s); err != nil { panic(err) } } -- cgit v1.2.3-2-g168b