summaryrefslogtreecommitdiff
path: root/src-3.0
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@chalmers.se>2008-05-21 19:51:52 +0000
committerkr.angelov <kr.angelov@chalmers.se>2008-05-21 19:51:52 +0000
commitb7ff446966e3299c61e79e9391f105b134b95b8a (patch)
tree71890b6ac271b24e6e5b58d1977fbf69263dcc4c /src-3.0
parentced73a2f0af799e46142ad89fedb2412ae19548f (diff)
further optimization by unpacking the ByteString in Ident
Diffstat (limited to 'src-3.0')
-rw-r--r--src-3.0/GF/Infra/Ident.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src-3.0/GF/Infra/Ident.hs b/src-3.0/GF/Infra/Ident.hs
index afe41f190..45ebf3a5b 100644
--- a/src-3.0/GF/Infra/Ident.hs
+++ b/src-3.0/GF/Infra/Ident.hs
@@ -29,13 +29,13 @@ import qualified Data.ByteString.Char8 as BS
-- | the constructors labelled /INTERNAL/ are
-- internal representation never returned by the parser
data Ident =
- IC !BS.ByteString -- ^ raw identifier after parsing, resolved in Rename
- | IW -- ^ wildcard
+ IC {-# UNPACK #-} !BS.ByteString -- ^ raw identifier after parsing, resolved in Rename
+ | IW -- ^ wildcard
--
-- below this constructor: internal representation never returned by the parser
- | IV !BS.ByteString Int -- ^ /INTERNAL/ variable
- | IA !BS.ByteString Int -- ^ /INTERNAL/ argument of cat at position
- | IAV !BS.ByteString Int Int -- ^ /INTERNAL/ argument of cat with bindings at position
+ | IV {-# UNPACK #-} !BS.ByteString {-# UNPACK #-} !Int -- ^ /INTERNAL/ variable
+ | IA {-# UNPACK #-} !BS.ByteString {-# UNPACK #-} !Int -- ^ /INTERNAL/ argument of cat at position
+ | IAV {-# UNPACK #-} !BS.ByteString {-# UNPACK #-} !Int {-# UNPACK #-} !Int -- ^ /INTERNAL/ argument of cat with bindings at position
--
deriving (Eq, Ord, Show, Read)
@@ -46,7 +46,7 @@ ident2bs i = case i of
IV s n -> BS.append s (BS.pack ('_':show n))
IA s j -> BS.append s (BS.pack ('_':show j))
IAV s b j -> BS.append s (BS.pack ('_':show b ++ '_':show j))
- IW -> BS.singleton '_'
+ IW -> BS.pack "_"
prIdent :: Ident -> String
prIdent i = BS.unpack $! ident2bs i
@@ -73,7 +73,7 @@ varStr = identA (BS.pack "str") 0
-- | refreshing variables
varX :: Int -> Ident
-varX = identV (BS.singleton 'x')
+varX = identV (BS.pack "x")
isWildIdent :: Ident -> Bool
isWildIdent x = case x of