[MLton-commit] r4385

Stephen Weeks MLton@mlton.org
Wed, 29 Mar 2006 14:04:28 -0800


Sped up the implementation of Real.{==,!=,isNan}.

Real.== no longer calls Real.class to ensure basis spec compliance.
Instead, it assumes that the primitive == does the right thing.

Real.isNan is now implemented with

  fun isNan r = r != r

This was about 4 times faster on my machine than the old version that
used Real.class.

Changed the primitive simplifier so that it doesn't simplify
Real_equal(x, x) to true, since this is incorrect for nans.


----------------------------------------------------------------------

U   mlton/trunk/basis-library/real/real.fun
U   mlton/trunk/mlton/atoms/prim.fun

----------------------------------------------------------------------

Modified: mlton/trunk/basis-library/real/real.fun
===================================================================
--- mlton/trunk/basis-library/real/real.fun	2006-03-29 00:21:10 UTC (rev 4384)
+++ mlton/trunk/basis-library/real/real.fun	2006-03-29 22:04:27 UTC (rev 4385)
@@ -105,19 +105,13 @@
           | NAN => false
           | _ => true
 
-      fun isNan r = class r = NAN
+      val op == = Prim.==
 
-      fun isNormal r = class r = NORMAL
+      val op != = not o op ==
 
-      val op == =
-         fn (x, y) =>
-         case (class x, class y) of
-            (NAN, _) => false
-          | (_, NAN) => false
-          | (ZERO, ZERO) => true
-          | _ => Prim.== (x, y)
+      fun isNan r = r != r
 
-      val op != = not o op ==
+      fun isNormal r = class r = NORMAL
 
       val op ?= =
          if MLton.Codegen.isNative

Modified: mlton/trunk/mlton/atoms/prim.fun
===================================================================
--- mlton/trunk/mlton/atoms/prim.fun	2006-03-29 00:21:10 UTC (rev 4384)
+++ mlton/trunk/mlton/atoms/prim.fun	2006-03-29 22:04:27 UTC (rev 4385)
@@ -1507,7 +1507,6 @@
                               | MLton_equal => t
                               | Real_lt _ => f
                               | Real_le _ => t
-                              | Real_equal _ => t
                               | Real_qequal _ => t
                               | Word_andb _ => Var x
                               | Word_equal _ => t