X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FEncoding.hs;h=c790f386a4bc9a51996e935f5c8e967a83c63144;hb=4767e535d9761920a18629a4142d3a929503b936;hp=6ca0d6eb4941733d8029f3ea4b0ac314b55244e8;hpb=17b297d97d327620ed6bfab942f8992b2446f1bf;p=ghc-hetmet.git diff --git a/compiler/utils/Encoding.hs b/compiler/utils/Encoding.hs index 6ca0d6e..c790f38 100644 --- a/compiler/utils/Encoding.hs +++ b/compiler/utils/Encoding.hs @@ -1,3 +1,7 @@ +{-# OPTIONS_GHC -O #-} +-- We always optimise this, otherwise performance of a non-optimised +-- compiler is severely affected + -- ----------------------------------------------------------------------------- -- -- (c) The University of Glasgow, 1997-2006 @@ -6,13 +10,6 @@ -- -- ----------------------------------------------------------------------------- -{-# OPTIONS_GHC -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings --- for details - module Encoding ( -- * UTF-8 utf8DecodeChar#, @@ -30,7 +27,6 @@ module Encoding ( zDecodeString ) where -#define COMPILING_FAST_STRING #include "HsVersions.h" import Foreign import Data.Char ( ord, chr, isDigit, digitToInt, intToDigit, @@ -141,8 +137,9 @@ countUTF8Chars ptr bytes = go ptr 0 | ptr >= end = return n | otherwise = do case utf8DecodeChar# (unPtr ptr) of - (# c, a #) -> go (Ptr a) (n+1) + (# _, a #) -> go (Ptr a) (n+1) +unPtr :: Ptr a -> Addr# unPtr (Ptr a) = a utf8EncodeChar :: Char -> Ptr Word8 -> IO (Ptr Word8) @@ -173,7 +170,7 @@ utf8EncodeChar c ptr = utf8EncodeString :: Ptr Word8 -> String -> IO () utf8EncodeString ptr str = go ptr str where STRICT2(go) - go ptr [] = return () + go _ [] = return () go ptr (c:cs) = do ptr' <- utf8EncodeChar c ptr go ptr' cs @@ -334,6 +331,7 @@ decode_lower 'v' = '%' decode_lower ch = {-pprTrace "decode_lower" (char ch)-} ch -- Characters not having a specific code are coded as z224U (in hex) +decode_num_esc :: Char -> EncodedString -> UserString decode_num_esc d rest = go (digitToInt d) rest where @@ -371,13 +369,13 @@ maybe_tuple :: UserString -> Maybe EncodedString maybe_tuple "(# #)" = Just("Z1H") maybe_tuple ('(' : '#' : cs) = case count_commas (0::Int) cs of - (n, '#' : ')' : cs) -> Just ('Z' : shows (n+1) "H") - other -> Nothing + (n, '#' : ')' : _) -> Just ('Z' : shows (n+1) "H") + _ -> Nothing maybe_tuple "()" = Just("Z0T") maybe_tuple ('(' : cs) = case count_commas (0::Int) cs of - (n, ')' : cs) -> Just ('Z' : shows (n+1) "T") - other -> Nothing -maybe_tuple other = Nothing + (n, ')' : _) -> Just ('Z' : shows (n+1) "T") + _ -> Nothing +maybe_tuple _ = Nothing count_commas :: Int -> String -> (Int, String) count_commas n (',' : cs) = count_commas (n+1) cs