X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FEncoding.hs;h=84b4e092f1288cfa538f033aec21a7a17e18acc7;hb=f2aaae9757e7532485c97f6c9a9ed5437542d1dd;hp=35df00478c9387024adaa94fa8c12fd69a6f7e99;hpb=911860671d3f35a52b54869a7a3e7730d7c631dd;p=ghc-hetmet.git diff --git a/compiler/utils/Encoding.hs b/compiler/utils/Encoding.hs index 35df004..84b4e09 100644 --- a/compiler/utils/Encoding.hs +++ b/compiler/utils/Encoding.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC -O #-} -- We always optimise this, otherwise performance of a non-optimised -- compiler is severely affected @@ -31,7 +32,6 @@ module Encoding ( import Foreign import Data.Char import Numeric -import Data.Bits import GHC.Ptr ( Ptr(..) ) import GHC.Base @@ -50,21 +50,21 @@ import GHC.Base {-# INLINE utf8DecodeChar# #-} utf8DecodeChar# :: Addr# -> (# Char#, Addr# #) utf8DecodeChar# a# = - let ch0 = word2Int# (indexWord8OffAddr# a# 0#) in + let !ch0 = word2Int# (indexWord8OffAddr# a# 0#) in case () of _ | ch0 <=# 0x7F# -> (# chr# ch0, a# `plusAddr#` 1# #) | ch0 >=# 0xC0# && ch0 <=# 0xDF# -> - let ch1 = word2Int# (indexWord8OffAddr# a# 1#) in + let !ch1 = word2Int# (indexWord8OffAddr# a# 1#) in if ch1 <# 0x80# || ch1 >=# 0xC0# then fail 1# else (# chr# (((ch0 -# 0xC0#) `uncheckedIShiftL#` 6#) +# (ch1 -# 0x80#)), a# `plusAddr#` 2# #) | ch0 >=# 0xE0# && ch0 <=# 0xEF# -> - let ch1 = word2Int# (indexWord8OffAddr# a# 1#) in + let !ch1 = word2Int# (indexWord8OffAddr# a# 1#) in if ch1 <# 0x80# || ch1 >=# 0xC0# then fail 1# else - let ch2 = word2Int# (indexWord8OffAddr# a# 2#) in + let !ch2 = word2Int# (indexWord8OffAddr# a# 2#) in if ch2 <# 0x80# || ch2 >=# 0xC0# then fail 2# else (# chr# (((ch0 -# 0xE0#) `uncheckedIShiftL#` 12#) +# ((ch1 -# 0x80#) `uncheckedIShiftL#` 6#) +# @@ -72,11 +72,11 @@ utf8DecodeChar# a# = a# `plusAddr#` 3# #) | ch0 >=# 0xF0# && ch0 <=# 0xF8# -> - let ch1 = word2Int# (indexWord8OffAddr# a# 1#) in + let !ch1 = word2Int# (indexWord8OffAddr# a# 1#) in if ch1 <# 0x80# || ch1 >=# 0xC0# then fail 1# else - let ch2 = word2Int# (indexWord8OffAddr# a# 2#) in + let !ch2 = word2Int# (indexWord8OffAddr# a# 2#) in if ch2 <# 0x80# || ch2 >=# 0xC0# then fail 2# else - let ch3 = word2Int# (indexWord8OffAddr# a# 3#) in + let !ch3 = word2Int# (indexWord8OffAddr# a# 3#) in if ch3 <# 0x80# || ch3 >=# 0xC0# then fail 3# else (# chr# (((ch0 -# 0xF0#) `uncheckedIShiftL#` 18#) +# ((ch1 -# 0x80#) `uncheckedIShiftL#` 12#) +# @@ -116,7 +116,7 @@ STRICT2(utf8DecodeString) utf8DecodeString (Ptr a#) (I# len#) = unpack a# where - end# = addr2Int# (a# `plusAddr#` len#) + !end# = addr2Int# (a# `plusAddr#` len#) unpack p# | addr2Int# p# >=# end# = return []