X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FFastString.lhs;h=ca7c2c71af80f0a4d8ca05094762de99262fbca6;hb=1a7d1b77334529ca96ed4cbc03fcb5f55dc2de4a;hp=ffe10c3a024d53bd15bea77f82f05ff43f45ac74;hpb=55551ce576db8530e305e552945a58cc070aa98c;p=ghc-hetmet.git diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs index ffe10c3..ca7c2c7 100644 --- a/compiler/utils/FastString.lhs +++ b/compiler/utils/FastString.lhs @@ -2,6 +2,13 @@ % (c) The University of Glasgow, 1997-2006 % \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + {- FastString: A compact, hash-consed, representation of character strings. Comparison is O(1), and you can get a Unique from them. @@ -78,11 +85,12 @@ import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) import System.IO ( hPutBuf ) import Data.Maybe ( isJust ) -import GHC.Arr ( STArray(..), newSTArray ) +import GHC.ST import GHC.IOBase ( IO(..) ) import GHC.Ptr ( Ptr(..) ) -#define hASH_TBL_SIZE 4091 +#define hASH_TBL_SIZE 4091 +#define hASH_TBL_SIZE_UNBOXED 4091# {-| @@ -165,8 +173,10 @@ data FastStringTable = string_table :: IORef FastStringTable string_table = unsafePerformIO $ do - (STArray _ _ arr#) <- stToIO (newSTArray (0::Int,hASH_TBL_SIZE) []) - newIORef (FastStringTable 0 arr#) + tab <- IO $ \s1# -> case newArray# hASH_TBL_SIZE_UNBOXED [] s1# of + (# s2#, arr# #) -> + (# s2#, FastStringTable 0 arr# #) + newIORef tab lookupTbl :: FastStringTable -> Int -> IO [FastString] lookupTbl (FastStringTable _ arr#) (I# i#) =