Skip to content

Commit

Permalink
Prepare Joveler.Compression.XZ 4.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ied206 committed Sep 1, 2023
1 parent 31200ad commit a130cfc
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Benchmark/BenchProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static void NativeGlobalInit(AlgorithmFlags flags)
// Joveler.Compression.ZLib cannot load two or more zlib at once.
if (flags.HasFlag(AlgorithmFlags.ZLibNg))
{
Joveler.Compression.ZLib.ZLibInitOptions initOpts = new Joveler.Compression.ZLib.ZLibInitOptions()
Joveler.Compression.ZLib.ZLibInitOptions initOpts = new Joveler.Compression.ZLib.ZLibInitOptions()
{
IsWindowsStdcall = false
};
Expand Down
3 changes: 1 addition & 2 deletions Joveler.Compression.XZ.Tests/XZStreamsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
Expand Down Expand Up @@ -629,7 +628,7 @@ private static void AbortDecompressTemplate(string sampleFileName, int threads)
Assert.IsNull(xzs);
}


}
#endregion
}
Expand Down
11 changes: 11 additions & 0 deletions Joveler.Compression.XZ/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## v4.x

### v4.3.0

Released in 2023-09-02

- (BREAKING CHANGE) XZ streams and helper classes are now sealed for better performance.
- ABI will not break unless you have created a derived class of XZ streams.
- Added the `Abort()` method to XZ streams. ([\#15](https://github.com/ied206/Joveler.Compression/pull/15)).
- When a user wants to abort the current operation, one can call `Abort()` for faster stream cleanup.
- Currently only the compression mode benefits from `Abort()`, especially multithreaded compression.
- The output stream will have an invalid state, and must be discarded right after calling `Abort()`.

### v4.2.3

Released in 2023-08-27
Expand Down
5 changes: 3 additions & 2 deletions Joveler.Compression.XZ/Joveler.Compression.XZ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PackageId>Joveler.Compression.XZ</PackageId>
<Title>Joveler.Compression.XZ</Title>
<Version>4.2.3</Version>
<Version>4.3.0</Version>
<Authors>Hajin Jang</Authors>
<Company>Joveler</Company>
<Description>XZ Utils (liblzma) pinvoke library for .NET.
Expand All @@ -21,7 +21,8 @@ Supports Windows, Linux and macOS.</Description>
<PackageProjectUrl>https://github.com/ied206/Joveler.Compression</PackageProjectUrl>
<PackageIcon>images\Logo.png</PackageIcon>
<RepositoryUrl>https://github.com/ied206/Joveler.Compression</RepositoryUrl>
<PackageReleaseNotes>- Update xz-utils to 5.4.4.</PackageReleaseNotes>
<PackageReleaseNotes>- XZ streams and helper classes are now sealed for better performance.
- Added the Abort() method to XZ streams for faster stream cleanup in aborting cases.</PackageReleaseNotes>
<PackageTags>xz xz-utils liblzma lzma lzma2 compress compression decompress decompression archive crc32 crc64 crc checksum native pinvoke interop</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.XZ/XZHardware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

namespace Joveler.Compression.XZ
{
public class XZHardware
public static class XZHardware
{
#region Hardware - PhysMem & CPU Threads
public static ulong PhysMem()
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.XZ/XZLoadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

namespace Joveler.Compression.XZ
{
internal class XZLoadManager : LoadManagerBase<XZLoader>
internal sealed class XZLoadManager : LoadManagerBase<XZLoader>
{
protected override string ErrorMsgInitFirst => "Please call XZInit.GlobalInit() first!";
protected override string ErrorMsgAlreadyLoaded => "Joveler.Compression.XZ is already initialized.";
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.XZ/XZLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

namespace Joveler.Compression.XZ
{
internal class XZLoader : DynLoaderBase
internal sealed class XZLoader : DynLoaderBase
{
#region Constructor
public XZLoader() : base() { }
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.XZ/XZMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

namespace Joveler.Compression.XZ
{
public class XZMemory
public static class XZMemory
{
#region MemUsage
/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions Joveler.Compression.XZ/XZStreams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public sealed class XZCompressOptions
/// <summary>
/// Size of the internal buffer.
/// </summary>
public int BufferSize { get; set; } = XZStream.DefaultBufferSize;
public int BufferSize { get; set; } = XZStreamBase.DefaultBufferSize;
/// <summary>
/// Whether to leave the base stream object open after disposing the xz stream object.
/// </summary>
Expand Down Expand Up @@ -162,11 +162,11 @@ public class XZDecompressOptions
/// <summary>
///
/// </summary>
public LzmaDecodingFlag DecodeFlags { get; set; } = XZStream.DefaultDecodingFlags;
public LzmaDecodingFlag DecodeFlags { get; set; } = XZStreamBase.DefaultDecodingFlags;
/// <summary>
/// Size of the internal buffer.
/// </summary>
public int BufferSize { get; set; } = XZStream.DefaultBufferSize;
public int BufferSize { get; set; } = XZStreamBase.DefaultBufferSize;
/// <summary>
/// Whether to leave the base stream object open after disposing the xz stream object.
/// </summary>
Expand Down Expand Up @@ -596,7 +596,7 @@ private void FreeLzmaStream()
// lzma_end frees memory allocated for coder data structures.
// It must be called to avoid memory leak.
if (_lzmaStream != null)
{
{
XZInit.Lib.LzmaEnd(_lzmaStream);
}
}
Expand All @@ -605,19 +605,19 @@ private void FreeLzmaStream()
/// Immediately aborts the current operation.
/// Internal XZ resources will be freed without flushing nor finalizing.
/// <para>The instance will not be able to perform any operations except disposing.</para>
/// <para>Data written to the BaseStream will become invalid, dispose it immediately.</para>
/// <para>Data written to the BaseStream will become invalid, discard it immediately.</para>
/// </summary>
public void Abort()
{
// In compress mode, Abort() is faster than Close().
// In threaded compress mode, Abort() is much faster than Close().
// In decompress mode, Abort() took similar time as Close().

// Invalidate LzmaStream instance.
// After running this code, liblzma will refuse any operations via this LzmaStream object.
if (_isAborted)
return;

FreeLzmaStream();
_isAborted = true;
}
Expand Down Expand Up @@ -899,7 +899,7 @@ public double CompressionRatio
}
#endregion



#region GetProgress
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.ZLib.Tests/ZLibInitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void LegacyInitCompatShim()
ZLibInit.GlobalCleanup();
ZLibInit.GlobalInit(libPath, new ZLibInitOptions() { IsWindowsStdcall = false });
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.ZLib/ZLibInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@ public static string VersionString()
}
#endregion
}
#endregion
#endregion
}
3 changes: 1 addition & 2 deletions Joveler.Compression.ZLib/ZLibLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ 3. This notice may not be removed or altered from any source distribution.
using Joveler.DynLoader;
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;

namespace Joveler.Compression.ZLib
{
Expand Down Expand Up @@ -334,7 +333,7 @@ public override void LoadFunctions()
InflatePtr = Lib.GetFuncPtr<inflate>(nameof(inflate));
InflateEndPtr = Lib.GetFuncPtr<inflateEnd>(nameof(inflateEnd));

ZLibCompileFlagsPtr = Lib.GetFuncPtr<zlibCompileFlags>(nameof(zlibCompileFlags));
ZLibCompileFlagsPtr = Lib.GetFuncPtr<zlibCompileFlags>(nameof(zlibCompileFlags));

base.LoadFunctions();
}
Expand Down
2 changes: 1 addition & 1 deletion Joveler.Compression.ZLib/ZLibStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public enum ZLibMemLevel : int
[StructLayout(LayoutKind.Sequential)]
internal abstract unsafe class ZStreamBase
{
public static uint DowncastCULong64(ulong val64, [CallerMemberName]string caller = "")
public static uint DowncastCULong64(ulong val64, [CallerMemberName] string caller = "")
{
if (uint.MaxValue < val64)
throw new OverflowException($"{caller}: [{val64}] cannot be represented in 32bit unsigned integer.");
Expand Down

0 comments on commit a130cfc

Please sign in to comment.