@@ -5,45 +5,23 @@ module HaskellWorks.Data.Xml.Conduit
55 ( blankedXmlToInterestBits
66 , byteStringToBits
77 , compressWordAsBit
8- , interestingWord8s
9- , isInterestingWord8
108 ) where
119
12- import Data.ByteString as BS
10+ import Data.ByteString ( ByteString )
1311import Data.Word
14- import Data.Word8
15- import HaskellWorks.Data.AtIndex ((!!!) )
1612import HaskellWorks.Data.Bits.BitWise
17- import Prelude as P
13+ import HaskellWorks.Data.Xml.Internal.ByteString
14+ import HaskellWorks.Data.Xml.Internal.Tables
15+ import Prelude
1816
19- import qualified Data.Bits as BITS
20- import qualified Data.Vector.Storable as DVS
17+ import qualified Data.Bits as BITS
18+ import qualified Data.ByteString as BS
19+ import qualified Prelude as P
2120
22- interestingWord8s :: DVS. Vector Word8
23- interestingWord8s = DVS. constructN 256 go
24- where go :: DVS. Vector Word8 -> Word8
25- go v = if w == _bracketleft
26- || w == _braceleft
27- || w == _parenleft
28- || w == _bracketleft
29- || w == _less
30- || w == _a
31- || w == _v
32- || w == _t
33- then 1
34- else 0
35- where w :: Word8
36- w = fromIntegral (DVS. length v)
37- {-# NOINLINE interestingWord8s #-}
38-
39- isInterestingWord8 :: Word8 -> Word8
40- isInterestingWord8 b = fromIntegral (interestingWord8s !!! fromIntegral b)
41- {-# INLINABLE isInterestingWord8 #-}
42-
43- blankedXmlToInterestBits :: [BS. ByteString ] -> [BS. ByteString ]
21+ blankedXmlToInterestBits :: [ByteString ] -> [ByteString ]
4422blankedXmlToInterestBits = blankedXmlToInterestBits' " "
4523
46- blankedXmlToInterestBits' :: BS. ByteString -> [BS. ByteString ] -> [BS. ByteString ]
24+ blankedXmlToInterestBits' :: ByteString -> [ByteString ] -> [ByteString ]
4725blankedXmlToInterestBits' rs is = case is of
4826 (bs: bss) -> do
4927 let cs = if BS. length rs /= 0 then BS. concat [rs, bs] else bs
@@ -63,16 +41,10 @@ blankedXmlToInterestBits' rs is = case is of
6341 , BS. drop 8 as
6442 )
6543
66- repartitionMod8 :: BS. ByteString -> BS. ByteString -> (BS. ByteString , BS. ByteString )
67- repartitionMod8 aBS bBS = (BS. take cLen abBS, BS. drop cLen abBS)
68- where abBS = BS. concat [aBS, bBS]
69- abLen = BS. length abBS
70- cLen = (abLen `div` 8 ) * 8
71-
72- compressWordAsBit :: [BS. ByteString ] -> [BS. ByteString ]
44+ compressWordAsBit :: [ByteString ] -> [ByteString ]
7345compressWordAsBit = compressWordAsBit' BS. empty
7446
75- compressWordAsBit' :: BS. ByteString -> [BS. ByteString ] -> [BS. ByteString ]
47+ compressWordAsBit' :: ByteString -> [ByteString ] -> [ByteString ]
7648compressWordAsBit' aBS iBS = case iBS of
7749 (bBS: bBSs) -> do
7850 let (cBS, dBS) = repartitionMod8 aBS bBS
@@ -103,7 +75,7 @@ yieldBitsOfWord8 w =
10375yieldBitsofWord8s :: [Word8 ] -> [Bool ]
10476yieldBitsofWord8s = P. foldr ((++) . yieldBitsOfWord8) []
10577
106- byteStringToBits :: [BS. ByteString ] -> [Bool ]
78+ byteStringToBits :: [ByteString ] -> [Bool ]
10779byteStringToBits is = case is of
10880 (bs: bss) -> yieldBitsofWord8s (BS. unpack bs) ++ byteStringToBits bss
10981 [] -> []
0 commit comments