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

Add SPECIALIZE pragmas for strict and lazy Text. #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/Text/Regex/TDFA/NewDFA/Engine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import Data.Sequence(Seq,ViewL(..),viewl)
import qualified Data.Sequence as Seq(null)
import qualified Data.ByteString.Char8 as SBS(ByteString)
import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)
import qualified Data.Text as ST(Text)
import qualified Data.Text.Lazy as LT(Text)

import Text.Regex.Base(MatchArray,MatchOffset,MatchLength)
import qualified Text.Regex.TDFA.IntArrTrieSet as Trie(lookupAsc)
Expand Down Expand Up @@ -69,9 +71,11 @@ err s = common_error "Text.Regex.TDFA.NewDFA.Engine" s
{-# INLINE set #-}
set :: (MArray a e (S.ST s),Ix i) => a i e -> Int -> e -> S.ST s ()
set = unsafeWrite

{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ([] Char) -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-}

{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> [] Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> Seq Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ST.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LT.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}
execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray]
Expand Down
10 changes: 7 additions & 3 deletions lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import Data.Sequence(Seq,ViewL(..),viewl)
import qualified Data.Sequence as Seq(null)
import qualified Data.ByteString.Char8 as SBS(ByteString)
import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)
import qualified Data.Text as ST(Text)
import qualified Data.Text.Lazy as LT(Text)

import Text.Regex.Base(MatchArray,MatchOffset,MatchLength)
import Text.Regex.TDFA.Common hiding (indent)
Expand All @@ -60,9 +62,11 @@ set = unsafeWrite

noSource :: ((Index, Instructions),STUArray s Tag Position,OrbitLog)
noSource = ((-1,err "noSource"),err "noSource",err "noSource")

{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ([] Char) -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-}

{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> [] Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> Seq Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ST.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LT.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}
execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray]
Expand Down
8 changes: 6 additions & 2 deletions lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import qualified Control.Monad.ST.Strict as S(ST)
import Data.Sequence(Seq)
import qualified Data.ByteString.Char8 as SBS(ByteString)
import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)
import qualified Data.Text as ST(Text)
import qualified Data.Text.Lazy as LT(Text)

import Text.Regex.Base(MatchArray,MatchOffset,MatchLength)
import qualified Text.Regex.TDFA.IntArrTrieSet as Trie(lookupAsc)
Expand All @@ -40,8 +42,10 @@ err s = common_error "Text.Regex.TDFA.NewDFA.Engine_NC" s
set :: (MArray a e (S.ST s),Ix i) => a i e -> Int -> e -> S.ST s ()
set = unsafeWrite

{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ([] Char) -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> [] Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> Seq Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ST.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LT.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}
execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray]
Expand Down
8 changes: 6 additions & 2 deletions lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import qualified Control.Monad.ST.Strict as S(ST,runST)
import Data.Sequence(Seq)
import qualified Data.ByteString.Char8 as SBS(ByteString)
import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)
import qualified Data.Text as ST(Text)
import qualified Data.Text.Lazy as LT(Text)

import Text.Regex.Base(MatchArray,MatchOffset,MatchLength)
import Text.Regex.TDFA.Common hiding (indent)
Expand All @@ -27,8 +29,10 @@ import Text.Regex.TDFA.NewDFA.MakeTest(test_singleline)
-- trace :: String -> a -> a
-- trace _ a = a

{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ([] Char) -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> [] Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> Seq Char -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> ST.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LT.Text -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-}
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}
execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray]
Expand Down
8 changes: 6 additions & 2 deletions lib/Text/Regex/TDFA/NewDFA/Tester.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ import qualified Data.IntSet as ISet(null)
import Data.Sequence(Seq)
import qualified Data.ByteString.Char8 as SBS(ByteString)
import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)
import qualified Data.Text as ST(Text)
import qualified Data.Text.Lazy as LT(Text)

import Text.Regex.Base()
import Text.Regex.TDFA.Common hiding (indent)
import Text.Regex.TDFA.NewDFA.Uncons (Uncons(uncons))
import Text.Regex.TDFA.NewDFA.MakeTest(test_singleline,test_multiline)

{-# SPECIALIZE matchTest :: Regex -> ([] Char) -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> (Seq Char) -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> [] Char -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> Seq Char -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> ST.Text -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> LT.Text -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> SBS.ByteString -> Bool #-}
{-# SPECIALIZE matchTest :: Regex -> LBS.ByteString -> Bool #-}
matchTest :: Uncons text => Regex -> text -> Bool
Expand Down