-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lazily initialize base state for Random-derived type (#81627)
When the legacy Random algorithm is used, which happens when a seed is supplied or when a type derived from Random is used, the state for the algorithm is initialized, including an int[56] that gets allocated. For a Random-derived type that overrides all of the base methods, however, that state is never used. We can create it lazily rather than at ctor time and avoid those base costs if they're never used. (I'd previously made several attempts at this, but each ended up with regressions up to 15%. Any regressions here appear to be within the noise, and even if they manifest, would only be limited to the case of Random-derived types that don't supply their own implementations.)
- Loading branch information
1 parent
faae476
commit fc1ce86
Showing
1 changed file
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters