Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bounds checking for table lookup #79

Merged
merged 1 commit into from Sep 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/HaskellWorks/Data/Xml/Conduit.hs
Expand Up @@ -11,9 +11,9 @@ module HaskellWorks.Data.Xml.Conduit
) where

import Data.ByteString as BS
import Data.Vector.Storable ((!))
import Data.Word
import Data.Word8
import HaskellWorks.Data.AtIndex ((!!!))
import HaskellWorks.Data.Bits.BitWise
import Prelude as P

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

isInterestingWord8 :: Word8 -> Word8
isInterestingWord8 b = fromIntegral (interestingWord8s ! fromIntegral b)
isInterestingWord8 b = fromIntegral (interestingWord8s !!! fromIntegral b)
{-# INLINABLE isInterestingWord8 #-}

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

Expand Down