projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add final newlines
[ghc-hetmet.git]
/
compiler
/
utils
/
StringBuffer.lhs
diff --git
a/compiler/utils/StringBuffer.lhs
b/compiler/utils/StringBuffer.lhs
index
1a30edb
..
3b2a3df
100644
(file)
--- a/
compiler/utils/StringBuffer.lhs
+++ b/
compiler/utils/StringBuffer.lhs
@@
-6,6
+6,10
@@
Buffers for scanning string input stored in external arrays.
\begin{code}
Buffers for scanning string input stored in external arrays.
\begin{code}
+{-# OPTIONS_GHC -O -funbox-strict-fields #-}
+-- We always optimise this, otherwise performance of a non-optimised
+-- compiler is severely affected
+
module StringBuffer
(
StringBuffer(..),
module StringBuffer
(
StringBuffer(..),
@@
-49,15
+53,7
@@
import System.IO ( hGetBuf, hFileSize,IOMode(ReadMode), hClose
import GHC.Exts
import GHC.Exts
-#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ >= 601
import System.IO ( openBinaryFile )
import System.IO ( openBinaryFile )
-#else
-import IOExts ( openFileEx, IOModeEx(..) )
-#endif
-
-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 601
-openBinaryFile fp mode = openFileEx fp (BinaryMode mode)
-#endif
-- -----------------------------------------------------------------------------
-- The StringBuffer type
-- -----------------------------------------------------------------------------
-- The StringBuffer type
@@
-133,12
+129,14
@@
appendStringBuffers sb1 sb2
withForeignPtr newBuf $ \ptr ->
withForeignPtr (buf sb1) $ \sb1Ptr ->
withForeignPtr (buf sb2) $ \sb2Ptr ->
withForeignPtr newBuf $ \ptr ->
withForeignPtr (buf sb1) $ \sb1Ptr ->
withForeignPtr (buf sb2) $ \sb2Ptr ->
- do copyArray (sb1Ptr `advancePtr` cur sb1) ptr (calcLen sb1)
- copyArray (sb2Ptr `advancePtr` cur sb2) (ptr `advancePtr` cur sb1) (calcLen sb2)
+ do copyArray ptr (sb1Ptr `advancePtr` cur sb1) sb1_len
+ copyArray (ptr `advancePtr` sb1_len) (sb2Ptr `advancePtr` cur sb2) sb2_len
pokeArray (ptr `advancePtr` size) [0,0,0]
return (StringBuffer newBuf size 0)
pokeArray (ptr `advancePtr` size) [0,0,0]
return (StringBuffer newBuf size 0)
- where calcLen sb = len sb - cur sb
- size = calcLen sb1 + calcLen sb2
+ where sb1_len = calcLen sb1
+ sb2_len = calcLen sb2
+ calcLen sb = len sb - cur sb
+ size = sb1_len + sb2_len
stringToStringBuffer :: String -> IO StringBuffer
stringToStringBuffer str = do
stringToStringBuffer :: String -> IO StringBuffer
stringToStringBuffer str = do