Move some of the JSON escape character matches under an appropriate guard
This commit is contained in:
parent
0c1b4da583
commit
8a1a082b53
1 changed files with 10 additions and 9 deletions
|
@ -651,17 +651,18 @@ slicedUtf8TextJson !src# !soff0# !slen0# = fromFunction reqLen $ \dst doff0 -> d
|
||||||
then case indexChar8Array (ByteArray src#) soff of
|
then case indexChar8Array (ByteArray src#) soff of
|
||||||
'\\' -> write2 dst doff '\\' '\\' *> go (soff + 1) (slen - 1) (doff + 2)
|
'\\' -> write2 dst doff '\\' '\\' *> go (soff + 1) (slen - 1) (doff + 2)
|
||||||
'\"' -> write2 dst doff '\\' '\"' *> go (soff + 1) (slen - 1) (doff + 2)
|
'\"' -> write2 dst doff '\\' '\"' *> go (soff + 1) (slen - 1) (doff + 2)
|
||||||
'\n' -> write2 dst doff '\\' 'n' *> go (soff + 1) (slen - 1) (doff + 2)
|
|
||||||
'\r' -> write2 dst doff '\\' 'r' *> go (soff + 1) (slen - 1) (doff + 2)
|
|
||||||
'\t' -> write2 dst doff '\\' 't' *> go (soff + 1) (slen - 1) (doff + 2)
|
|
||||||
c -> if c >= '\x20'
|
c -> if c >= '\x20'
|
||||||
then PM.writeByteArray dst doff (c2w c) *> go (soff + 1) (slen - 1) (doff + 1)
|
then PM.writeByteArray dst doff (c2w c) *> go (soff + 1) (slen - 1) (doff + 1)
|
||||||
else do
|
else case c of
|
||||||
write2 dst doff '\\' 'u'
|
'\n' -> write2 dst doff '\\' 'n' *> go (soff + 1) (slen - 1) (doff + 2)
|
||||||
doff' <- UnsafeBounded.pasteST
|
'\r' -> write2 dst doff '\\' 'r' *> go (soff + 1) (slen - 1) (doff + 2)
|
||||||
(Bounded.word16PaddedUpperHex (fromIntegral (c2w c)))
|
'\t' -> write2 dst doff '\\' 't' *> go (soff + 1) (slen - 1) (doff + 2)
|
||||||
dst (doff + 2)
|
_ -> do
|
||||||
go (soff + 1) (slen - 1) doff'
|
write2 dst doff '\\' 'u'
|
||||||
|
doff' <- UnsafeBounded.pasteST
|
||||||
|
(Bounded.word16PaddedUpperHex (fromIntegral (c2w c)))
|
||||||
|
dst (doff + 2)
|
||||||
|
go (soff + 1) (slen - 1) doff'
|
||||||
else pure doff
|
else pure doff
|
||||||
doffRes <- go (I# soff0#) (I# slen0#) (doff0 + 1)
|
doffRes <- go (I# soff0#) (I# slen0#) (doff0 + 1)
|
||||||
PM.writeByteArray dst doffRes (c2w '"')
|
PM.writeByteArray dst doffRes (c2w '"')
|
||||||
|
|
Loading…
Reference in a new issue