Skip to content

Commit

Permalink
src: Consistent curly braces for loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-lucas6 committed May 13, 2023
1 parent ffbaf90 commit 5490a98
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/Geralt.Tests/SpansTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ private static T[] Concat<T>(params T[][] arrays)
{
int offset = 0;
var result = new T[arrays.Sum(array => array.Length)];
foreach (var array in arrays)
{
foreach (var array in arrays) {
Array.Copy(array, sourceIndex: 0, result, offset, array.Length);
offset += array.Length;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Geralt/Crypto/BLAKE2b.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public static void ComputeHash(Span<byte> hash, Stream message)
int bytesRead;
Span<byte> buffer = new byte[StreamBufferSize];
using var blake2b = new IncrementalBLAKE2b(hash.Length);
while ((bytesRead = message.Read(buffer)) > 0)
{
while ((bytesRead = message.Read(buffer)) > 0) {
blake2b.Update(buffer[..bytesRead]);
}
CryptographicOperations.ZeroMemory(buffer);
Expand Down
6 changes: 2 additions & 4 deletions src/Geralt/Crypto/SecureRandom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public static string GetString(int length, string characterSet = AlphanumericCha
Validation.SizeBetween(nameof(length), length, MinStringLength, MaxStringLength);
Validation.NotNullOrEmpty(nameof(characterSet), characterSet);
var stringBuilder = new StringBuilder();
for (int i = 0; i < length; i++)
{
for (int i = 0; i < length; i++) {
stringBuilder.Append(characterSet[GetInt32(characterSet.Length)]);
}
return stringBuilder.ToString();
Expand All @@ -61,8 +60,7 @@ public static char[] GetPassphrase(int wordCount, char separatorChar = '-', bool
int numberIndex = 0;
if (includeNumber) { numberIndex = GetInt32(wordCount); }
var passphrase = new List<char>();
for (int i = 0; i < wordCount; i++)
{
for (int i = 0; i < wordCount; i++) {
int randomIndex = GetInt32(wordlist.Length);
passphrase.AddRange(capitalize ? CultureInfo.InvariantCulture.TextInfo.ToTitleCase(wordlist[randomIndex]) : wordlist[randomIndex]);
if (includeNumber && i == numberIndex) { passphrase.Add(char.Parse(GetInt32(NumericChars.Length).ToString())); }
Expand Down

0 comments on commit 5490a98

Please # to comment.