summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorich@christoph-bauer.net <unknown>2010-02-27 21:16:59 +0000
committerich@christoph-bauer.net <unknown>2010-02-27 21:16:59 +0000
commit789690fc23a49aa3bcbc946992fd6340c90d8c10 (patch)
tree84364d5a9d28f84e85f8eb7a2187e1ccf5cf3c17 /compiler
parent51ab3ed19f55e386c4e55efd2cd6705789f8fbf4 (diff)
downloadhaskell-789690fc23a49aa3bcbc946992fd6340c90d8c10.tar.gz
a faster appendFS
Diffstat (limited to 'compiler')
-rw-r--r--compiler/utils/FastString.lhs13
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs
index 29c7788c2f..055f921213 100644
--- a/compiler/utils/FastString.lhs
+++ b/compiler/utils/FastString.lhs
@@ -449,7 +449,18 @@ zEncodeFS fs@(FastString _ _ _ _ enc) =
return efs
appendFS :: FastString -> FastString -> FastString
-appendFS fs1 fs2 = mkFastString (unpackFS fs1 ++ unpackFS fs2)
+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
concatFS :: [FastString] -> FastString
concatFS ls = mkFastString (Prelude.concat (map unpackFS ls)) -- ToDo: do better