[Issue 3738] MinstdRand0 and MinstdRand very poor performance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 24 09:19:05 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3738


Andrei Alexandrescu <andrei at metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|nobody at puremagic.com        |andrei at metalanguage.com


--- Comment #4 from Andrei Alexandrescu <andrei at metalanguage.com> 2010-01-24 09:19:04 PST ---
Here's the modified version as I plan to commit:

    void popFront()
    {
        static if (m)
        {
            static if (is(UIntType == uint) && m == uint.max)
            {
                immutable ulong
                    x = (cast(ulong) a * _x + c),
                    v = x >> 32,
                    w = x & uint.max;
                immutable y = cast(uint)(v + w);
                _x = (y < v || y == uint.max) ? (y + 1) : y;
            }
            else static if (is(UIntType == uint) && m == int.max)
            {
                immutable ulong
                    x = (cast(ulong) a * _x + c),
                    v = x >> 31,
                    w = x & int.max;
                const uint y = cast(uint)(v + w);
                _x = (y >= int.max) ? ((y + 1) & int.max) : y;
            }
            else
            {
                _x = cast(UIntType) ((cast(ulong) a * _x + c) % m);
            }
        }
        else
        {
            _x = a * _x + c;
        }
    }

I changed formatting a bit and literals with symbolic constants. Unfortunately
unittests don't fail when I slightly change some constants :o|.

Looks good?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list