From 86a30ef99213670b305934a4d0976d458db7db97 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 2 Oct 2008 13:23:54 +0000 Subject: Converted GF/Source/*.hs to Unix line endings, to be able to see what happens when I regenerated the files. --- src/GF/Source/SharedString.hs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/GF/Source/SharedString.hs') diff --git a/src/GF/Source/SharedString.hs b/src/GF/Source/SharedString.hs index 732873fe6..358f70494 100644 --- a/src/GF/Source/SharedString.hs +++ b/src/GF/Source/SharedString.hs @@ -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' -- cgit v1.2.3