Skip to content

Commit 90577aa

Browse files
committed
Use ArgumentNullException.ThrowIfNull() to check arguments
1 parent 1eaa10b commit 90577aa

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

src/Kavod.Vba.Compression/CompressedChunk.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ internal class CompressedChunk
1616
{
1717
internal CompressedChunk(DecompressedChunk decompressedChunk)
1818
{
19-
if (decompressedChunk == null)
20-
{
21-
throw new ArgumentNullException(nameof(decompressedChunk));
22-
}
19+
ArgumentNullException.ThrowIfNull(decompressedChunk);
2320

2421
ChunkData = new CompressedChunkData(decompressedChunk);
2522
if (ChunkData.Size >= Globals.MaxBytesPerChunk)
@@ -31,10 +28,7 @@ internal CompressedChunk(DecompressedChunk decompressedChunk)
3128

3229
internal CompressedChunk(BinaryReader dataReader)
3330
{
34-
if (dataReader == null)
35-
{
36-
throw new ArgumentNullException(nameof(dataReader));
37-
}
31+
ArgumentNullException.ThrowIfNull(dataReader);
3832

3933
Header = new CompressedChunkHeader(dataReader);
4034
if (Header.IsCompressed)

src/Kavod.Vba.Compression/CompressedChunkData.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ internal class CompressedChunkData : IChunkData
1818

1919
internal CompressedChunkData(DecompressedChunk chunk)
2020
{
21-
if (chunk == null)
22-
{
23-
throw new ArgumentNullException(nameof(chunk));
24-
}
21+
ArgumentNullException.ThrowIfNull(chunk);
2522

2623
var tokens = Tokenizer.TokenizeUncompressedData(chunk.Data);
2724
_tokensequences.AddRange(tokens.ToTokenSequences());

src/Kavod.Vba.Compression/Tokenizer.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ private static IEnumerable<CopyToken> RemoveOverlappingTokens(IEnumerable<CopyTo
162162

163163
private static Node FindBestPath(Node node)
164164
{
165-
if (node == null)
166-
{
167-
throw new ArgumentNullException(nameof(node));
168-
}
165+
ArgumentNullException.ThrowIfNull(node);
169166

170167
// find any overlapping tokens
171168
Node bestPath = null;
@@ -191,10 +188,7 @@ private static Node FindBestPath(Node node)
191188

192189
private static IEnumerable<Node> GetOverlappingNodes(Node node)
193190
{
194-
if (node == null)
195-
{
196-
throw new ArgumentNullException(nameof(node));
197-
}
191+
ArgumentNullException.ThrowIfNull(node);
198192

199193
var firstNode = node;
200194

@@ -208,10 +202,7 @@ private static IEnumerable<Node> GetOverlappingNodes(Node node)
208202

209203
private static Node GetNextNonOverlappingNode(Node node)
210204
{
211-
if (node == null)
212-
{
213-
throw new ArgumentNullException(nameof(node));
214-
}
205+
ArgumentNullException.ThrowIfNull(node);
215206

216207
var firstNode = node;
217208

@@ -322,10 +313,7 @@ private class Node : IEnumerable<CopyToken>
322313
{
323314
public Node(CopyToken value, Node nextNode)
324315
{
325-
if (value == null)
326-
{
327-
throw new ArgumentNullException(nameof(value));
328-
}
316+
ArgumentNullException.ThrowIfNull(value);
329317

330318
Value = value;
331319
NextNode = nextNode;

0 commit comments

Comments
 (0)