Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Optimize RandomLetter
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozenreflex committed Aug 23, 2022
1 parent 40f9779 commit 0af06da
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Logix/Math/Random/RandomLetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ protected override void OnEvaluate()
{
var start = MathX.Clamp(StartOfAlphabet.EvaluateRaw(), 0, 26);
var end = MathX.Clamp(EndOfAlphabet.EvaluateRaw(26), start, 26);
var flag = UseUppercase.EvaluateRaw();
Value.Value = flag ?
Value.Value = UseUppercase.EvaluateRaw() ?
RandomX.UPPERCASE_ALPHABET[RandomX.Range(start, end)] :
RandomX.LOWERCASE_ALPHABET[RandomX.Range(start, end)];
}
Expand Down

2 comments on commit 0af06da

@DoubleStyx
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the C# compiler make these kinds of substitutions? I guess there's no harm in doing the substitution manually as long as there isn't any loss in readability.

@art0007i
Copy link
Contributor

@art0007i art0007i commented on 0af06da Aug 23, 2022

Choose a reason for hiding this comment

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

I would even say it's an improvement to readability, but yeah the compiler will make that substitution (I checked on sharplab.io)

edit: it will, but only if you build in release mode, in debug it will actually keep the local variable, you can mess with it yourself, the above link stores the code I used to test

Please sign in to comment.