diff --git a/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs b/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs index 437e25c10..5aced2d71 100644 --- a/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs +++ b/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs @@ -1,5 +1,6 @@ using System; using System.Security.Cryptography; +using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Encryption { @@ -163,7 +164,7 @@ public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int input { throw new NotImplementedException("TransformFinalBlock is not implemented and inputCount is greater than 0"); } - return new byte[0]; + return Empty.Array(); } /// diff --git a/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs b/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs index 64a1e5e18..262c12ad3 100644 --- a/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs +++ b/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Text; +using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Tar { @@ -465,7 +466,7 @@ public TarEntry[] GetDirectoryEntries() { if ((file == null) || !Directory.Exists(file)) { - return new TarEntry[0]; + return Empty.Array(); } string[] list = Directory.GetFileSystemEntries(file); diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs index 0535b1250..4e075dc8d 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip { @@ -521,7 +522,7 @@ public ZipExtraData(byte[] data) { if (data == null) { - _data = new byte[0]; + _data = Empty.Array(); } else { @@ -552,7 +553,7 @@ public void Clear() { if ((_data == null) || (_data.Length != 0)) { - _data = new byte[0]; + _data = Empty.Array(); } } diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index 704911b3f..a99f1f5ba 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -539,7 +539,7 @@ public ZipFile(Stream stream, bool leaveOpen) } else { - entries_ = new ZipEntry[0]; + entries_ = Empty.Array(); isNewArchive_ = true; } } @@ -549,7 +549,7 @@ public ZipFile(Stream stream, bool leaveOpen) /// internal ZipFile() { - entries_ = new ZipEntry[0]; + entries_ = Empty.Array(); isNewArchive_ = true; } @@ -2338,7 +2338,7 @@ private int WriteCentralDirectoryHeader(ZipEntry entry) baseStream_.Write(centralExtraData, 0, centralExtraData.Length); } - byte[] rawComment = (entry.Comment != null) ? Encoding.ASCII.GetBytes(entry.Comment) : new byte[0]; + byte[] rawComment = (entry.Comment != null) ? Encoding.ASCII.GetBytes(entry.Comment) : Empty.Array(); if (rawComment.Length > 0) { @@ -3347,7 +3347,7 @@ private void DisposeInternal(bool disposing) if (!isDisposed_) { isDisposed_ = true; - entries_ = new ZipEntry[0]; + entries_ = Empty.Array(); if (IsStreamOwner && (baseStream_ != null)) { diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs index 3c49ec8cb..e2c0426fd 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs @@ -872,7 +872,7 @@ public override void Finish() byte[] entryComment = (entry.Comment != null) ? ZipStrings.ConvertToArray(entry.Flags, entry.Comment) : - new byte[0]; + Empty.Array(); if (entryComment.Length > 0xffff) { @@ -987,7 +987,7 @@ public override void Flush() /// /// Comment for the entire archive recorded in central header. /// - private byte[] zipComment = new byte[0]; + private byte[] zipComment = Empty.Array(); /// /// Flag indicating that header patching is required for the current entry. diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipStrings.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipStrings.cs index 6ef523b82..8c2447134 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipStrings.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipStrings.cs @@ -1,5 +1,6 @@ using System; using System.Text; +using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip { @@ -174,7 +175,7 @@ public static string ConvertToStringExt(int flags, byte[] data) /// Converted array public static byte[] ConvertToArray(string str) => str == null - ? new byte[0] + ? Empty.Array() : Encoding.GetEncoding(CodePage).GetBytes(str); /// @@ -187,7 +188,7 @@ public static byte[] ConvertToArray(string str) /// Converted array public static byte[] ConvertToArray(int flags, string str) => (string.IsNullOrEmpty(str)) - ? new byte[0] + ? Empty.Array() : EncodingFromFlag(flags).GetBytes(str); } }