diff options
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) |