strict bytestring encoders and decoders
Only had lazy ones before. Already sped up a few parts of the code.
This commit is contained in:
parent
9cc6d5549b
commit
b3c69eaaf8
14 changed files with 41 additions and 25 deletions
|
@ -22,7 +22,6 @@ import qualified Data.Aeson
|
|||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.Set
|
||||
import qualified Data.Vector
|
||||
import Prelude
|
||||
|
@ -53,7 +52,7 @@ instance ToJSON' String where
|
|||
-- Note that if the string contains invalid UTF8 characters not using
|
||||
-- the FileSystemEncoding, this is the same as Data.Text.pack.
|
||||
packString :: String -> T.Text
|
||||
packString s = case T.decodeUtf8' (S.concat $ L.toChunks $ encodeBS s) of
|
||||
packString s = case T.decodeUtf8' (encodeBS s) of
|
||||
Right t -> t
|
||||
Left _ -> T.pack s
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue