Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily initialize base state for Random-derived type #81627

Merged
merged 1 commit into from
Feb 14, 2023

Commits on Feb 4, 2023

  1. Lazily initialize base state for Random-derived type

    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.)
    stephentoub committed Feb 4, 2023
    Configuration menu
    Copy the full SHA
    03ae327 View commit details
    Browse the repository at this point in the history