[MLton-commit] r7220

Wesley Terpstra wesley at mlton.org
Thu Aug 20 06:40:52 PDT 2009


When using 'MLton.safe false' but still detecting overflow, 
the let clause inserts a useless multiply and overflow test.


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

U   mlton/trunk/basis-library/integer/pack-word.sml

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

Modified: mlton/trunk/basis-library/integer/pack-word.sml
===================================================================
--- mlton/trunk/basis-library/integer/pack-word.sml	2009-08-02 22:25:03 UTC (rev 7219)
+++ mlton/trunk/basis-library/integer/pack-word.sml	2009-08-20 13:40:52 UTC (rev 7220)
@@ -26,10 +26,10 @@
 
 fun offset (i, n) = 
    let
-      val i' = Int.* (bytesPerElem, i)
       val () =
          if Primitive.Controls.safe
-            andalso (Int.geu (Int.+ (i', Int.- (bytesPerElem, 1)), n))
+            andalso (Int.geu (Int.+ (Int.* (bytesPerElem, i), 
+                                     Int.- (bytesPerElem, 1)), n))
             then raise Subscript
             else ()
    in




More information about the MLton-commit mailing list