[MLton-commit] r5985

Vesa Karvonen vesak at mlton.org
Sat Sep 1 05:57:24 PDT 2007


Omit the tag when a sum has only 1 variant.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml

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

Modified: mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml
===================================================================
--- mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml	2007-09-01 10:37:51 UTC (rev 5984)
+++ mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml	2007-09-01 12:57:23 UTC (rev 5985)
@@ -184,9 +184,11 @@
       {rd = I.map b2a rd, wr = wr o a2b, sz = sz}
    end
 
+   val unit = {rd = I.return (), wr = fn () => O.return (), sz = SOME 0}
    val char = {rd = I.read, wr = O.write, sz = SOME 1}
    val word8 = iso' id char word8Ichar
-   val intAs8  = iso' id char (swap Char.isoInt)
+   val intAs8 = iso' id char (swap Char.isoInt)
+   val intAs0 = iso' id unit (ignore, const 0)
 
    (* Pickles a positive int using a variable length encoding. *)
    val size =
@@ -551,7 +553,7 @@
                 sz = OptInt.+ (sL, sR)}
             end
       end
-      val unit = {rd = I.return (), wr = fn () => O.return (), sz = SOME 0}
+      val unit = unit
       fun C0 _ i = {rd = const (I.return ()),
                     wr = fn wrTag => const (wrTag i),
                     sz = SOME 0}
@@ -563,7 +565,8 @@
       fun data s = let
          val n = Arg.numAlts s
          val tag =
-             if      n < 256   then intAs8
+             if      n = 1     then intAs0
+             else if n < 256   then intAs8
              else if n < 65536 then intAs16
              else fail "Too many tags"
          val {rd, wr, sz} = getS s 0




More information about the MLton-commit mailing list