[MLton-commit] r5888

Vesa Karvonen vesak at mlton.org
Sun Aug 19 04:24:47 PDT 2007


Minor optimization.
Updated copyright year.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-integer-ext.fun
U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-integer-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-integer-ext.fun	2007-08-17 18:08:44 UTC (rev 5887)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-integer-ext.fun	2007-08-19 11:24:46 UTC (rev 5888)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2006 SSH Communications Security, Helsinki, Finland
+(* Copyright (C) 2006-2007 SSH Communications Security, Helsinki, Finland
  *
  * This code is released under the MLton license, a BSD-style license.
  * See the LICENSE file or http://mlton.org/License for details.

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun	2007-08-17 18:08:44 UTC (rev 5887)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/numeric/mk-word-ext.fun	2007-08-19 11:24:46 UTC (rev 5888)
@@ -58,16 +58,13 @@
          val fromBigBytes = mk BasisWord8Vector.foldl
          val fromLittleBytes = mk BasisWord8Vector.foldr
       end
+      fun intPrec p = case BasisInt.precision of NONE => false | SOME n => p n
       val toFixedInt =
-          if case BasisInt.precision
-              of NONE   => false
-               | SOME n => BasisInt.< (wordSize, n)
+          if intPrec (fn n => BasisInt.< (wordSize, n))
           then BasisFixedInt.fromInt o toInt
           else BasisFixedInt.fromLarge o toLargeInt
       val toFixedIntX =
-          if case BasisInt.precision
-              of NONE   => false
-               | SOME n => BasisInt.<= (wordSize, n)
+          if intPrec (fn n => BasisInt.<= (wordSize, n))
           then BasisFixedInt.fromInt o toIntX
           else BasisFixedInt.fromLarge o toLargeIntX
       val fromWord = fromLarge o BasisWord.toLarge
@@ -91,7 +88,10 @@
       val toWord8 = BasisWord8.fromInt o toIntX
       val toWord8X = toWord8
       val toWordX = BasisWord.fromLarge o toLargeX
-      val fromFixedInt = fromLargeInt o BasisFixedInt.toLarge
+      val fromFixedInt =
+          if intPrec (fn n => n = valOf BasisFixedInt.precision)
+          then fromInt o BasisFixedInt.toInt
+          else fromLargeInt o BasisFixedInt.toLarge
       val embString = (toString, fromString)
       val isoBigBytes = (toBigBytes, fromBigBytes)
       val isoFixedInt = (toFixedInt, fromFixedInt)




More information about the MLton-commit mailing list