FastTypes - note strictness of fast{Or,And} and make the unboxed versions so
authorIsaac Dupree <id@isaac.cedarswampstudios.org>
Mon, 30 Apr 2007 19:58:10 +0000 (19:58 +0000)
committerIsaac Dupree <id@isaac.cedarswampstudios.org>
Mon, 30 Apr 2007 19:58:10 +0000 (19:58 +0000)
compiler/utils/FastTypes.lhs

index bcea61d..9d7c276 100644 (file)
@@ -34,6 +34,8 @@ fastBool True  = 1#
 fastBool False = 0#
 isFastTrue x = x ==# 1#
 
+-- note that fastOr and fastAnd are strict in both arguments
+-- since they are unboxed
 fastOr 1# _ = 1#
 fastOr 0# x = x
 
@@ -60,8 +62,12 @@ negateFastInt = negate
 type FastBool = Bool
 fastBool x = x
 isFastTrue x = x
-fastOr = (||)
-fastAnd = (&&)
+-- make sure these are as strict as the unboxed version,
+-- so that the performance characteristics match
+fastOr False False = False
+fastOr _ _ = True
+fastAnd True True = True
+fastAnd _ _ = False
 
 --These are among the type-signatures necessary for !ghc to compile
 -- but break ghc (can't give a signature for an import...)