Huw Davies (@huw) commented about dlls/ntdll/rtl.c:
- result = *seed * 0xffffffed + 0x7fffffc3; - if (result == 0xffffffff || result == 0x7ffffffe) { - result = (result + 2) & MAXLONG; - } else if (result == 0x7fffffff) { - result = 0; - } else if ((result & 0x80000000) == 0) { - result = result + (~result & 1); - } else { - result = (result + (result & 1)) & MAXLONG; - } /* if */ + /* The algorithm below is equivalent to the following expression: + * + * result = ((ULONGLONG)*seed * 0x7fffffed + 0x7fffffc3) % 0x7fffffff; + * return (*seed = result); + */ + The optimization below doesn't seem to be worth it. On x86_64 I couldn't measure a difference between the algorithm above and the optimization below. On i386, while the optimization was about 10% faster, the algorithm above matched native's performance, so there seems little point in adding the complexity.
If you really need the optimization, you could potentially introduce it in a later MR. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/821#note_24059