From 33e925937aa71f2a75ba721ccc41b5ab2ef5a8dc Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Tue, 3 Dec 2019 17:51:31 +1100 Subject: [PATCH] Add SPECIALIZE pragmas for strict and lazy Text. --- lib/Text/Regex/TDFA/NewDFA/Engine.hs | 10 +++++++--- lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs | 10 +++++++--- lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs | 8 ++++++-- lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs | 8 ++++++-- lib/Text/Regex/TDFA/NewDFA/Tester.hs | 8 ++++++-- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/Text/Regex/TDFA/NewDFA/Engine.hs b/lib/Text/Regex/TDFA/NewDFA/Engine.hs index edfaf72..898ee6d 100644 --- a/lib/Text/Regex/TDFA/NewDFA/Engine.hs +++ b/lib/Text/Regex/TDFA/NewDFA/Engine.hs @@ -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) @@ -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] diff --git a/lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs b/lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs index 30f8ce2..75030e1 100644 --- a/lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs +++ b/lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs @@ -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) @@ -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] diff --git a/lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs b/lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs index ffa4b18..897a1e3 100644 --- a/lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs +++ b/lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs @@ -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) @@ -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] diff --git a/lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs b/lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs index af783e3..315a19f 100644 --- a/lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs +++ b/lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs @@ -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) @@ -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] diff --git a/lib/Text/Regex/TDFA/NewDFA/Tester.hs b/lib/Text/Regex/TDFA/NewDFA/Tester.hs index 62a1b01..018c822 100644 --- a/lib/Text/Regex/TDFA/NewDFA/Tester.hs +++ b/lib/Text/Regex/TDFA/NewDFA/Tester.hs @@ -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