Converted GF/Source/*.hs to Unix line endings, to be able to see what happens when I regenerated the files.

This commit is contained in:
bjorn
2008-10-02 13:23:54 +00:00
parent 8fb068df6a
commit 86a30ef992
8 changed files with 9866 additions and 9866 deletions

View File

@@ -1,20 +1,20 @@
module GF.Source.SharedString (shareString) where
import Data.Map as M
import Data.IORef
import qualified Data.ByteString.Char8 as BS
import System.IO.Unsafe (unsafePerformIO)
{-# NOINLINE stringPoolRef #-}
stringPoolRef :: IORef (M.Map BS.ByteString BS.ByteString)
stringPoolRef = unsafePerformIO $ newIORef M.empty
{-# NOINLINE shareString #-}
shareString :: BS.ByteString -> BS.ByteString
shareString s = unsafePerformIO $ do
stringPool <- readIORef stringPoolRef
case M.lookup s stringPool of
Just s' -> return s'
Nothing -> do let s' = BS.copy s
writeIORef stringPoolRef $! M.insert s' s' stringPool
return s'
module GF.Source.SharedString (shareString) where
import Data.Map as M
import Data.IORef
import qualified Data.ByteString.Char8 as BS
import System.IO.Unsafe (unsafePerformIO)
{-# NOINLINE stringPoolRef #-}
stringPoolRef :: IORef (M.Map BS.ByteString BS.ByteString)
stringPoolRef = unsafePerformIO $ newIORef M.empty
{-# NOINLINE shareString #-}
shareString :: BS.ByteString -> BS.ByteString
shareString s = unsafePerformIO $ do
stringPool <- readIORef stringPoolRef
case M.lookup s stringPool of
Just s' -> return s'
Nothing -> do let s' = BS.copy s
writeIORef stringPoolRef $! M.insert s' s' stringPool
return s'