Skip to content

Commit

Permalink
Use Array.Empty() if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
Drake53 authored and mmanela committed Jan 6, 2023
1 parent 70825b4 commit 99a00fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions DiffPlex/Chunkers/LineEndingsPreservingChunker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ namespace DiffPlex.Chunkers
{
public class LineEndingsPreservingChunker:IChunker
{
private readonly string[] emptyArray = new string[0];
#if NETSTANDARD1_3_OR_GREATER || NET46_OR_GREATER || NETCOREAPP
private static readonly string[] emptyStringArray = System.Array.Empty<string>();
#else
private static readonly string[] emptyStringArray = new string[0];
#endif

/// <summary>
/// Gets the default singleton instance of the chunker.
Expand All @@ -14,7 +18,7 @@ public class LineEndingsPreservingChunker:IChunker
public string[] Chunk(string text)
{
if (string.IsNullOrEmpty(text))
return emptyArray;
return emptyStringArray;

var output = new List<string>();
var lastCut = 0;
Expand Down
5 changes: 4 additions & 1 deletion DiffPlex/Differ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ namespace DiffPlex
{
public class Differ : IDiffer
{

#if NETSTANDARD1_3_OR_GREATER || NET46_OR_GREATER || NETCOREAPP
private static readonly string[] emptyStringArray = Array.Empty<string>();
#else
private static readonly string[] emptyStringArray = new string[0];
#endif

/// <summary>
/// Gets the default singleton instance of differ instance.
Expand Down

0 comments on commit 99a00fb

Please sign in to comment.