Skip to content

Commit c74ab60

Browse files
authored
Merge pull request #79 from haskell-works/remove-bounds-checking-for-table-lookup
Remove bounds checking for table lookup
2 parents dfbcc27 + 2c1aa27 commit c74ab60

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/HaskellWorks/Data/Xml/Conduit.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module HaskellWorks.Data.Xml.Conduit
1111
) where
1212

1313
import Data.ByteString as BS
14-
import Data.Vector.Storable ((!))
1514
import Data.Word
1615
import Data.Word8
16+
import HaskellWorks.Data.AtIndex ((!!!))
1717
import HaskellWorks.Data.Bits.BitWise
1818
import Prelude as P
1919

@@ -38,7 +38,7 @@ interestingWord8s = DVS.constructN 256 go
3838
{-# NOINLINE interestingWord8s #-}
3939

4040
isInterestingWord8 :: Word8 -> Word8
41-
isInterestingWord8 b = fromIntegral (interestingWord8s ! fromIntegral b)
41+
isInterestingWord8 b = fromIntegral (interestingWord8s !!! fromIntegral b)
4242
{-# INLINABLE isInterestingWord8 #-}
4343

4444
blankedXmlToInterestBits :: [BS.ByteString] -> [BS.ByteString]
@@ -60,7 +60,7 @@ blankedXmlToInterestBits' rs is = case is of
6060
where gen :: ByteString -> Maybe (Word8, ByteString)
6161
gen as = if BS.length as == 0
6262
then Nothing
63-
else Just ( BS.foldr' (\b m -> (interestingWord8s ! fromIntegral b) .|. (m .<. 1)) 0 (BS.take 8 as)
63+
else Just ( BS.foldr' (\b m -> isInterestingWord8 b .|. (m .<. 1)) 0 (BS.take 8 as)
6464
, BS.drop 8 as
6565
)
6666

0 commit comments

Comments
 (0)