https://bugzilla.novell.com/show_bug.cgi?id=405052

User [EMAIL PROTECTED] added comment
https://bugzilla.novell.com/show_bug.cgi?id=405052#c2


Marek Safar <[EMAIL PROTECTED]> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                                        |NEW
      Info Provider|[EMAIL PROTECTED]                               |




--- Comment #2 from Marek Safar <[EMAIL PROTECTED]>  2008-06-30 11:03:09 MDT ---
Ouch, I forget to attach the test program.

using System;

using System.Diagnostics;



namespace Test

{

        class Program

        {

                static void Main ()

                {

                        Stopwatch sw = new Stopwatch ();

                        sw.Start ();

                        int r = 0;

                        for (int i = 0; i < 20000000; ++i) {

                                r = GetHashCode ("a");

                                r = GetHashCode ("abc");

                                r = GetHashCode ("abcd");

                                r = GetHashCode ("abcdef");

                                r = GetHashCode ("abcdefghijklm");

                                r = GetHashCode ("abcdefghij");

                        }

                        sw.Stop ();

                        Console.WriteLine (sw.Elapsed);

                        Console.WriteLine (r);

                }



                public static unsafe int GetHashCode (string s)

                {
                        fixed (char* c = s) {

                                char* cc = c;

                                char* end = cc + s.Length - 1;

                                int h = 23;

                                while (cc < end) {

                                        h = (h << 5) * 37 + *cc;

                                        h = (h << 5) * 37 + cc [1];

                                        cc += 2;

                                }

                                ++end;

                                if (cc < end)

                                        h = (h << 5) * 37 + *cc;

                                return h;

                        }

                }

        }

}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to