File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -322,14 +322,20 @@ jstring_ = do
322
322
-- not sure whether >= or bit hackery is faster
323
323
-- perfectly, we shouldn't care, it's compiler job.
324
324
s <- A. takeWhile (\ w -> w /= DOUBLE_QUOTE && w /= BACKSLASH && w >= 0x20 && w < 0x80 )
325
- let txt = TE. decodeUtf8 s
325
+ let txt = unsafeDecodeASCII s
326
326
mw <- A. peekWord8
327
327
case mw of
328
328
Nothing -> fail " string without end"
329
329
Just DOUBLE_QUOTE -> A. anyWord8 $> txt
330
330
Just w | w < 0x20 -> fail " unescaped control character"
331
331
_ -> jstringSlow s
332
332
333
+ -- | The input is assumed to contain only 7bit ASCII characters (i.e. @< 0x80@).
334
+ -- We use TE.decodeLatin1 here because TE.decodeASCII is currently (text-1.2.4.0)
335
+ -- deprecated and equal to TE.decodeUtf8, which is slower than TE.decodeLatin1.
336
+ unsafeDecodeASCII :: B. ByteString -> Text
337
+ unsafeDecodeASCII = TE. decodeLatin1
338
+
333
339
jstringSlow :: B. ByteString -> Parser Text
334
340
{-# INLINE jstringSlow #-}
335
341
jstringSlow s' = {-# SCC "jstringSlow" #-} do
You can’t perform that action at this time.
0 commit comments