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

Use random shared #907

Merged
merged 9 commits into from
Dec 10, 2022
Merged

Use random shared #907

merged 9 commits into from
Dec 10, 2022

Conversation

leotsarev
Copy link
Contributor

Advantages:

  • Do not allocate Random & GlobalRandom instances on .NET 6
  • Common Random implementation in Random() and other places

@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Merging #907 (0359123) into master (4e09ca4) will increase coverage by 0.00%.
The diff coverage is 71.42%.

@@           Coverage Diff           @@
##           master     #907   +/-   ##
=======================================
  Coverage   92.39%   92.39%           
=======================================
  Files         111      112    +1     
  Lines        3443     3444    +1     
  Branches     1021     1021           
=======================================
+ Hits         3181     3182    +1     
  Misses        200      200           
  Partials       62       62           
Impacted Files Coverage Δ
MoreLinq/Random.cs 91.89% <ø> (+6.47%) ⬆️
MoreLinq/GlobalRandom.cs 66.66% <66.66%> (ø)
MoreLinq/RandomSubset.cs 100.00% <100.00%> (ø)
MoreLinq/Shuffle.cs 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@atifaziz atifaziz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

I've made some minor changes:

  • Reduced the scope of conditional parts within GlobalRandom.
  • Fixed the doc comment (anchor, grammar and formatting).
  • Conditionally imported System.Threading on .NET 6+.
  • Added the note of using Random.Shared on .NET 6+ to the various Random* methods.
  • Undid the move of GlobalRandom into a separate file since it's an unrelated change that can go into a follow-up PR (if absolutely necessary) and at which point the type could be un-nested too.

The net effect is a smaller diff.

@atifaziz atifaziz merged commit eeddf4d into morelinq:master Dec 10, 2022
@leotsarev leotsarev deleted the use-random-shared branch December 12, 2022 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants