X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FStringBuffer.lhs;h=5d1bfa60861781e17bf8528ad1bb7e33bdeceebd;hp=1aead2d74becab083e66257dba8cba551456b77e;hb=5289f5d85610f71625a439747a09384876655eb5;hpb=2a21b894d36ad83797bd46aa683297c3d466d3bb diff --git a/compiler/utils/StringBuffer.lhs b/compiler/utils/StringBuffer.lhs index 1aead2d..5d1bfa6 100644 --- a/compiler/utils/StringBuffer.lhs +++ b/compiler/utils/StringBuffer.lhs @@ -6,6 +6,7 @@ Buffers for scanning string input stored in external arrays. \begin{code} +{-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC -O -funbox-strict-fields #-} -- We always optimise this, otherwise performance of a non-optimised -- compiler is severely affected @@ -138,8 +139,9 @@ appendStringBuffers sb1 sb2 calcLen sb = len sb - cur sb size = sb1_len + sb2_len -stringToStringBuffer :: String -> IO StringBuffer -stringToStringBuffer str = do +stringToStringBuffer :: String -> StringBuffer +stringToStringBuffer str = + unsafePerformIO $ do let size = utf8EncodedLength str buf <- mallocForeignPtrArray (size+3) withForeignPtr buf $ \ptr -> do @@ -224,7 +226,7 @@ parseUnsignedInteger (StringBuffer buf _ cur) len radix char_to_int --LOL, in implementations where the indexing needs slow unsafePerformIO, --this is less (not more) efficient than using the IO monad explicitly --here. - ptr' = pUnbox ptr + !ptr' = pUnbox ptr byteOff i = cBox (indexWord8OffFastPtrAsFastChar ptr' (iUnbox (cur + i))) go i x | i == len = x | otherwise = case byteOff i of