[Mono-dev] Patch for Math.cs

Alan McGovern alan.mcgovern at gmail.com
Sun Mar 4 20:19:31 EST 2007


Forgive the terrible indenting on the code: http://pastebin.ca/381736

But that indicates a huge difference between performance when using turnary
as opposed to if/else. Turns out if/else is much much faster.

What the hell?

Alan.

On 3/5/07, Felipe Almeida Lessa <felipe.lessa at gmail.com> wrote:
>
> I'm not a Mono dev so I may be wrong, but see my two comments below.
>
> On 3/4/07, Dennis Hayes <denisraytek at yahoo.com> wrote:
> > @@ -411,26 +411,25 @@
> >  #if NET_2_0
> >                 public static double Round (double value,
> MidpointRounding
> > mode)
> >                 {
> > -                       if ((mode != MidpointRounding.ToEven) && (mode
> !=
> > MidpointRounding.AwayFromZero))
> > -                               throw new ArgumentException ("The value
> '" +
> > mode + "' is not valid for this usage of the type MidpointRounding.",
> > "mode");
> > -
> >                         if (mode == MidpointRounding.ToEven)
> >                                 return Round (value);
> >                         if (value > 0)
> >                                 return Floor (value + 0.5);
> >                         else
> >                                 return Ceiling (value - 0.5);
> > +
> > +                       throw new ArgumentException ("The value '" +
> mode +
> > "' is not valid for this usage of the type MidpointRounding.", "mode");
> >                 }
>
>
> Is it just me or this throw is non-reachable? The if clause just
> before it should catch every possible paths (that could lead to it).
>
>
>
> >                 [MonoTODO ("Not implemented")]
> >                 public static double Round (double value, int digits,
> > MidpointRounding mode)
> >                 {
> > -                       if ((mode != MidpointRounding.ToEven) && (mode
> !=
> > MidpointRounding.AwayFromZero))
> > -                               throw new ArgumentException ("The value
> '" +
> > mode + "' is not valid for this usage of the type MidpointRounding.",
> > "mode");
> > -
> > -                       if (mode == MidpointRounding.ToEven)
> > +            if (mode == MidpointRounding.ToEven)
> >                                 return Round (value, digits);
> > -                       throw new NotImplementedException ();
> > +                       if (mode == MidpointRounding.ToEven)
> > +                           throw new NotImplementedException ();
> > +
> > +                       throw new ArgumentException ("The value '" +
> mode +
> > "' is not valid for this usage of the type MidpointRounding.", "mode");
> >                 }
>
>
> Two checks to MidpointRounding.ToEven? The second one is unreachable
> as well (although I don't know if the compiler is clever enough to
> discover that). I suppose you meant MidpointRounding.AwayFromZero on
> the second if.
>
>
> HTH,
>
> --
> Felipe.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070305/26fc2b08/attachment.html 


More information about the Mono-devel-list mailing list