[Mono-dev] Int32.CompareTo() enhancement
Alan McGovern
alan.mcgovern at gmail.com
Thu Nov 22 16:52:59 EST 2007
Scratch that, it fails the NUnit tests :)
Alan.
On Nov 22, 2007 9:25 PM, Zoltan Varga <vargaz at gmail.com> wrote:
> Hi,
>
> This looks ok to check in, altough the int xv = assignment is no longer
> needed.
>
> Zoltan
>
> On Nov 22, 2007 10:05 PM, Alan McGovern <alan.mcgovern at gmail.com> wrote:
> > I was just looking at the source of int32, and i noticed that there was
> room
> > for improvement in the implementation of CompareTo.
> >
> > This implementation is approx 33% faster than the existing one. Is this
> ok
> > to commit? I can write the changelog and commit myself if i get the
> > go-ahead:
> >
> > Index: Int32.cs
> > ===================================================================
> > --- Int32.cs (revision 90185)
> > +++ Int32.cs (working copy)
> > @@ -57,12 +57,7 @@
> > throw new ArgumentException (
> Locale.GetText
> > ("Value is not a System.Int32"));
> >
> > int xv = (int) v;
> > - if (m_value == xv)
> > - return 0;
> > - if (m_value > xv)
> > - return 1;
> > - else
> > - return -1;
> > + return m_value - v;
> > }
> >
> > public override bool Equals (object o)
> > @@ -81,12 +76,7 @@
> > #if NET_2_0
> > public int CompareTo (int value)
> > {
> > - if (m_value == value)
> > - return 0;
> > - if (m_value > value)
> > - return 1;
> > - else
> > - return -1;
> > + return m_value - value;
> > }
> >
> >
> > _______________________________________________
> > 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/20071122/d275dacf/attachment.html
More information about the Mono-devel-list
mailing list