Skip to content

Commit c910a81

Browse files
Add default seed values
1 parent ad01391 commit c910a81

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/ImageSharp/Formats/Png/Zlib/Adler32.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
1717
/// </summary>
1818
internal static class Adler32
1919
{
20+
/// <summary>
21+
/// The default initial seed value of a Adler32 checksum calculation.
22+
/// </summary>
23+
public const uint SeedValue = 1U;
24+
2025
#if SUPPORTS_RUNTIME_INTRINSICS
2126
private const int MinBufferSize = 64;
2227
#endif
@@ -34,7 +39,7 @@ internal static class Adler32
3439
/// <returns>The <see cref="uint"/>.</returns>
3540
[MethodImpl(InliningOptions.ShortMethod)]
3641
public static uint Calculate(ReadOnlySpan<byte> buffer)
37-
=> Calculate(1U, buffer);
42+
=> Calculate(SeedValue, buffer);
3843

3944
/// <summary>
4045
/// Calculates the Adler32 checksum with the bytes taken from the span and seed.
@@ -47,7 +52,7 @@ public static uint Calculate(uint adler, ReadOnlySpan<byte> buffer)
4752
{
4853
if (buffer.IsEmpty)
4954
{
50-
return 1U;
55+
return SeedValue;
5156
}
5257

5358
#if SUPPORTS_RUNTIME_INTRINSICS

src/ImageSharp/Formats/Png/Zlib/Crc32.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
1717
/// </summary>
1818
internal static partial class Crc32
1919
{
20+
/// <summary>
21+
/// The default initial seed value of a Crc32 checksum calculation.
22+
/// </summary>
23+
public const uint SeedValue = 0U;
24+
2025
#if SUPPORTS_RUNTIME_INTRINSICS
2126
private const int MinBufferSize = 64;
2227
private const int ChunksizeMask = 15;
@@ -36,7 +41,7 @@ internal static partial class Crc32
3641
/// <returns>The <see cref="uint"/>.</returns>
3742
[MethodImpl(InliningOptions.ShortMethod)]
3843
public static uint Calculate(ReadOnlySpan<byte> buffer)
39-
=> Calculate(0U, buffer);
44+
=> Calculate(SeedValue, buffer);
4045

4146
/// <summary>
4247
/// Calculates the CRC checksum with the bytes taken from the span and seed.
@@ -49,7 +54,7 @@ public static uint Calculate(uint crc, ReadOnlySpan<byte> buffer)
4954
{
5055
if (buffer.IsEmpty)
5156
{
52-
return 0U;
57+
return SeedValue;
5358
}
5459

5560
#if SUPPORTS_RUNTIME_INTRINSICS

src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal sealed class ZlibDeflateStream : Stream
2121
/// <summary>
2222
/// Computes the checksum for the data stream.
2323
/// </summary>
24-
private uint adler = 1U;
24+
private uint adler = Adler32.SeedValue;
2525

2626
/// <summary>
2727
/// A value indicating whether this instance of the given entity has been disposed.

0 commit comments

Comments
 (0)