summaryrefslogtreecommitdiff
path: root/encode_string.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-02-07 14:06:12 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-02-07 14:06:12 -0700
commit480ccfd05a13ac36516c536a71203280a31b4d28 (patch)
tree4ae21bf95c9f3b4cce97a0a0473fe622fdb393eb /encode_string.go
parent87013d526ea1b0647ef6e08758fe587cee11d854 (diff)
parent47549aa3d10808c063d45dcaa598887dadde59c5 (diff)
Merge branch 'lukeshu/fixup'
Diffstat (limited to 'encode_string.go')
-rw-r--r--encode_string.go26
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)
}
}