Skip to content

Commit 1c63a5a

Browse files
committed
Merge #138 changes
1 parent 46948ba commit 1c63a5a

File tree

5 files changed

+7
-19
lines changed

5 files changed

+7
-19
lines changed

CodeJam.Main/Algorithms/Algorithms.Swap.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ public static partial class Algorithms
1313
/// <typeparam name="T">Type of values</typeparam>
1414
/// <param name="value1">First value to swap.</param>
1515
/// <param name="value2">Second value to swap.</param>
16-
public static void Swap<T>(ref T value1, ref T value2)
17-
{
18-
var temp = value1;
19-
value1 = value2;
20-
value2 = temp;
21-
}
16+
public static void Swap<T>(ref T value1, ref T value2) => (value1, value2) = (value2, value1);
2217
}
2318
}

CodeJam.Main/ExceptionExtensions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public static void ToDiagnosticString(
7575

7676
switch (ex)
7777
{
78-
case FileNotFoundException notFoundException:
79-
var fex = notFoundException;
80-
78+
case FileNotFoundException fex:
8179
writer.WriteLine($"File Name: {fex.FileName}");
8280

8381
if (fex.GetFusionLog().IsNullOrEmpty())
@@ -155,9 +153,7 @@ private static async Task ToDiagnosticStringImplAsync(
155153

156154
switch (ex)
157155
{
158-
case FileNotFoundException notFoundException:
159-
var fex = notFoundException;
160-
156+
case FileNotFoundException fex:
161157
await writer.WriteLineAsync($"File Name: {fex.FileName}").ConfigureAwait(false);
162158

163159
if (fex.GetFusionLog().IsNullOrEmpty())

CodeJam.Main/Ranges/[Boundaries]/RangeBoundaryFrom`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public partial struct RangeBoundaryFrom<T> :
6969
public static RangeBoundaryFrom<T> AdjustAndCreate(T? value, RangeBoundaryFromKind boundaryKind)
7070
{
7171
DebugCode.AssertArgument(
72-
boundaryKind == RangeBoundaryFromKind.Inclusive || boundaryKind == RangeBoundaryFromKind.Exclusive,
72+
boundaryKind is RangeBoundaryFromKind.Inclusive or RangeBoundaryFromKind.Exclusive,
7373
nameof(boundaryKind),
7474
"The boundary kind should be be either Inclusive or Exclusive");
7575

CodeJam.Main/Structures/Option/Option`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public bool Equals(Option<T>? other)
100100

101101
var otherSome = other as Some;
102102

103-
if (!(this is Some))
103+
if (this is not Some)
104104
return otherSome is null;
105105

106106
if (otherSome is null)

CodeJam.Main/Threading/ParallelExtensions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,10 @@ public static void RunInParallel(
120120
string processName = "ParallelProcess")
121121
{
122122
Code.NotNull(source, nameof(source));
123-
123+
124124
using var queue = new ParallelQueue(parallelCount, processName + '_');
125125
foreach (var action in source)
126-
{
127-
var data = action;
128-
queue.EnqueueItem(data);
129-
}
126+
queue.EnqueueItem(action);
130127

131128
queue.WaitAll();
132129
}

0 commit comments

Comments
 (0)