diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-16 22:30:54 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-16 22:30:54 -0700 |
commit | debef01cc500fb9368e1d6d0206a32ca358a8c98 (patch) | |
tree | f021ae7890922e10a1aa119dcdbd7dd2a587f09e /decode.go | |
parent | d7414035894f378c9e1d48b04a767f61b082186a (diff) | |
parent | f823342d5b9c2ca376d038471889176ab74acf1b (diff) |
Merge branch 'lukeshu/misc'
Diffstat (limited to 'decode.go')
-rw-r--r-- | decode.go | 28 |
1 files changed, 9 insertions, 19 deletions
@@ -1145,7 +1145,7 @@ func (dec *Decoder) decodeString(gTyp reflect.Type, out fastio.RuneWriter) *Deco if err := dec.expectRuneType('"', jsonparse.RuneTypeStringBeg, gTyp); err != nil { return err } - var uhex [4]byte + var uhex [3]byte for { c, t, err := dec.readRune() if err != nil { @@ -1178,18 +1178,13 @@ func (dec *Decoder) decodeString(gTyp reflect.Type, out fastio.RuneWriter) *Deco panic(fmt.Errorf("should not happen: unexpected rune after backslash: %q", c)) } case jsonparse.RuneTypeStringEscUA: - uhex[0], _ = jsonparse.HexToInt(c) + uhex[0] = byte(c) case jsonparse.RuneTypeStringEscUB: - uhex[1], _ = jsonparse.HexToInt(c) + uhex[1] = byte(c) case jsonparse.RuneTypeStringEscUC: - uhex[2], _ = jsonparse.HexToInt(c) + uhex[2] = byte(c) case jsonparse.RuneTypeStringEscUD: - uhex[3], _ = jsonparse.HexToInt(c) - c = 0 | - rune(uhex[0])<<12 | - rune(uhex[1])<<8 | - rune(uhex[2])<<4 | - rune(uhex[3])<<0 + c = hexToRune(uhex[0], uhex[1], uhex[2], byte(c)) handleUnicode: if utf16.IsSurrogate(c) { t, err := dec.peekRuneType() @@ -1219,27 +1214,22 @@ func (dec *Decoder) decodeString(gTyp reflect.Type, out fastio.RuneWriter) *Deco if err != nil { return err } - uhex[0], _ = jsonparse.HexToInt(b) + uhex[0] = byte(b) b, _, err = dec.readRune() if err != nil { return err } - uhex[1], _ = jsonparse.HexToInt(b) + uhex[1] = byte(b) b, _, err = dec.readRune() if err != nil { return err } - uhex[2], _ = jsonparse.HexToInt(b) + uhex[2] = byte(b) b, _, err = dec.readRune() if err != nil { return err } - uhex[3], _ = jsonparse.HexToInt(b) - c2 := 0 | - rune(uhex[0])<<12 | - rune(uhex[1])<<8 | - rune(uhex[2])<<4 | - rune(uhex[3])<<0 + c2 := hexToRune(uhex[0], uhex[1], uhex[2], byte(b)) d := utf16.DecodeRune(c, c2) if d == utf8.RuneError { _, _ = out.WriteRune(utf8.RuneError) |