diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 12:18:29 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 14:05:26 -0700 |
commit | 2b9473f5e8816eeea76b2fdada184532be00d3a2 (patch) | |
tree | 387757b00f02521d1b3824a0e92f7778dbd32440 /encode_string.go | |
parent | eab38672b2467810592b61fe5b0067086d3cbd2c (diff) |
internal: Split in to sub-packages
Diffstat (limited to 'encode_string.go')
-rw-r--r-- | encode_string.go | 26 |
1 files changed, 14 insertions, 12 deletions
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) } } |