[commit: ghc] master: Redefine appendFS in terms of appendFB (2f01deb)
Ian Lynagh
igloo at earth.li
Fri Jul 20 15:46:47 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/2f01debc33a3ba60feaf2f9add0778bbd2ab81c2
>---------------------------------------------------------------
commit 2f01debc33a3ba60feaf2f9add0778bbd2ab81c2
Author: Ian Lynagh <igloo at earth.li>
Date: Sat Jul 14 22:11:14 2012 +0100
Redefine appendFS in terms of appendFB
I think the old definition had a bug, although it probably never
actually bit us: It used lengthFS to work out how large the arguments
where, but lengthFS returns the number of characters, not bytes.
>---------------------------------------------------------------
compiler/utils/FastString.lhs | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs
index a340e6e..29965b1 100644
--- a/compiler/utils/FastString.lhs
+++ b/compiler/utils/FastString.lhs
@@ -540,18 +540,10 @@ zEncodeFS fs@(FastString _ _ _ _ enc) =
return efs
appendFS :: FastString -> FastString -> FastString
-appendFS fs1 fs2 =
- inlinePerformIO $ do
- r <- mallocForeignPtrBytes len
- withForeignPtr r $ \ r' -> do
- withForeignPtr (buf fs1) $ \ fs1Ptr -> do
- withForeignPtr (buf fs2) $ \ fs2Ptr -> do
- copyBytes r' fs1Ptr len1
- copyBytes (advancePtr r' len1) fs2Ptr len2
- mkFastStringForeignPtr r' r len
- where len = len1 + len2
- len1 = lengthFS fs1
- len2 = lengthFS fs2
+appendFS fs1 fs2 = inlinePerformIO
+ $ mkFastStringFastBytes
+ $ appendFB (fastStringToFastBytes fs1)
+ (fastStringToFastBytes fs2)
concatFS :: [FastString] -> FastString
concatFS ls = mkFastString (Prelude.concat (map unpackFS ls)) -- ToDo: do better
More information about the Cvs-ghc
mailing list