From 509d2ad24e377b8f9d3487ab7a3b2c3d1d936eaa Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 15 Jul 2012 00:10:27 +0100 Subject: Add a separate FastZString type FastStrings are now always UTF8-encoded. There's no StringTable for FastZString, but I don't think one is needed. We only ever make a FastZString by running zEncodeFS on a FastString, and the FastStrings are shared via the FastString StringTable, so we get the same FastZString from the IORef. --- ghc/Main.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'ghc') diff --git a/ghc/Main.hs b/ghc/Main.hs index b65f9124c1..a53912c926 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -715,12 +715,11 @@ dumpFinalStats dflags = dumpFastStringStats :: DynFlags -> IO () dumpFastStringStats dflags = do buckets <- getFastStringTable - let (entries, longest, is_z, has_z) = countFS 0 0 0 0 buckets + let (entries, longest, has_z) = countFS 0 0 0 buckets msg = text "FastString stats:" $$ nest 4 (vcat [text "size: " <+> int (length buckets), text "entries: " <+> int entries, text "longest chain: " <+> int longest, - text "z-encoded: " <+> (is_z `pcntOf` entries), text "has z-encoding: " <+> (has_z `pcntOf` entries) ]) -- we usually get more "has z-encoding" than "z-encoded", because @@ -732,17 +731,16 @@ dumpFastStringStats dflags = do where x `pcntOf` y = int ((x * 100) `quot` y) <> char '%' -countFS :: Int -> Int -> Int -> Int -> [[FastString]] -> (Int, Int, Int, Int) -countFS entries longest is_z has_z [] = (entries, longest, is_z, has_z) -countFS entries longest is_z has_z (b:bs) = +countFS :: Int -> Int -> Int -> [[FastString]] -> (Int, Int, Int) +countFS entries longest has_z [] = (entries, longest, has_z) +countFS entries longest has_z (b:bs) = let len = length b longest' = max len longest entries' = entries + len - is_zs = length (filter isZEncoded b) has_zs = length (filter hasZEncoding b) in - countFS entries' longest' (is_z + is_zs) (has_z + has_zs) bs + countFS entries' longest' (has_z + has_zs) bs -- ----------------------------------------------------------------------------- -- ABI hash support -- cgit v1.2.1