diff --git a/CHANGELOG.md b/CHANGELOG.md index 4addacc..26f2ab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Revision history for json-syntax -## 0.3.0.1 -- 2025-07-14 +## 0.3.0.2 -- 2025-07-14 * Switch from ShortText to Text. In many cases, this makes it possible for the resulting Value to share the input byte array instead of allocating additional diff --git a/json-syntax.cabal b/json-syntax.cabal index 5182493..2494051 100644 --- a/json-syntax.cabal +++ b/json-syntax.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: json-syntax -version: 0.3.0.1 +version: 0.3.0.2 synopsis: High-performance JSON parser and encoder description: This library parses JSON into a @Value@ type that is consistent with the @@ -28,7 +28,7 @@ extra-doc-files: CHANGELOG.md README.md -tested-with: GHC ==9.4.8 || ==9.6.3 || ==9.8.1 +tested-with: GHC ==9.6.3 || ==9.8.1 common build-settings default-language: Haskell2010 diff --git a/src/Json.hs b/src/Json.hs index b86274d..c59b454 100644 --- a/src/Json.hs +++ b/src/Json.hs @@ -83,7 +83,7 @@ import Control.Monad.ST (ST, runST) import Control.Monad.ST.Run (runSmallArrayST) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Except (except, runExceptT) -import Data.Bits (unsafeShiftR, (.&.), (.|.), xor) +import Data.Bits (unsafeShiftR, (.&.), (.|.)) import Data.Builder.ST (Builder) import Data.Bytes.Chunks (Chunks) import Data.Bytes.Parser (Parser) @@ -94,12 +94,12 @@ import Data.Number.Scientific (Scientific) import Data.Primitive (Array, ByteArray (ByteArray), MutableByteArray, Prim, PrimArray, SmallArray) import Data.Text.Internal (Text(Text)) import Data.Text.Short (ShortText) -import GHC.Exts (Char (C#), Int (I#), chr#, gtWord#, ltWord#, word2Int#, minusWord#) -import GHC.Exts (Int#, ByteArray#, word8ToWord#, word16ToWord#) +import GHC.Exts (Char (C#), Int (I#), ltWord#, minusWord#) +import GHC.Exts (Int#, ByteArray#, word8ToWord#) import GHC.Exts (RuntimeRep(IntRep,TupleRep,BoxedRep), Levity(Unlifted)) import GHC.Exts (and#, xor#) import GHC.Int (Int16, Int32, Int64, Int8) -import GHC.Word (Word16(W16#), Word32, Word64, Word8(W8#), Word(W#)) +import GHC.Word (Word16, Word32, Word64, Word8(W8#), Word(W#)) import qualified Data.Builder.ST as B import qualified Data.ByteString.Short.Internal as BSS @@ -115,11 +115,9 @@ import qualified Data.List as List import qualified Data.Number.Scientific as SCI import qualified Data.Primitive as PM import qualified Data.Primitive.Contiguous as Contiguous -import qualified Data.Text import qualified Data.Text.Short as TS import qualified Data.Text.Short.Unsafe as TS import qualified Prelude -import qualified Data.Bytes.Parser.Rebindable as RB {- | The JSON syntax tree described by the ABNF in RFC 7159. Notable design decisions include: @@ -552,9 +550,10 @@ copyAndEscape# !maxLen = 0x22 -> (P.effect (PM.unsafeFreezeByteArray =<< PM.resizeMutableByteArray dst ix)) `P.bindFromLiftedToByteArrayIntInt` \str -> - P.pureByteArrayIntInt $ case byteArrayToShortByteString str of - BSS.SBS str' -> -- error ("Escaped string: " ++ Data.Text.unpack (Text (ByteArray str') 0 (I# ix#))) - (# str', 0#, ix# #) + P.pureByteArrayIntInt + ( case byteArrayToShortByteString str of + BSS.SBS str' -> (# str', 0#, ix# #) + ) _ | theCharW >= 0x20, theCharW < 127 -> (P.effect (PM.writeByteArray dst ix theCharW)) `P.bindFromLiftedToByteArrayIntInt` \_ ->