From bcbaa497a7a42bfee043572dafda3c9afb68d1c1 Mon Sep 17 00:00:00 2001 From: ArchLeaders Date: Sat, 16 Mar 2024 10:14:11 -0700 Subject: [PATCH] Code cleanup --- src/RstbLibrary/Helpers/Crc32.cs | 16 ++++++++-------- src/RstbLibrary/ImmutableRstb.cs | 8 ++++---- src/RstbLibrary/Structures/HashEntry.cs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/RstbLibrary/Helpers/Crc32.cs b/src/RstbLibrary/Helpers/Crc32.cs index 7237d30..70779c2 100644 --- a/src/RstbLibrary/Helpers/Crc32.cs +++ b/src/RstbLibrary/Helpers/Crc32.cs @@ -2,9 +2,9 @@ public class Crc32 { - private const uint Seed = 0xFFFFFFFF; + private const uint SEED = 0xFFFFFFFF; - private static readonly uint[] Table = [ + private static readonly uint[] _table = [ 0x00000000, 0x77073096, 0xEE0E612C, @@ -267,12 +267,12 @@ public class Crc32 public static uint Compute(ReadOnlySpan data, int offset, int length) { uint crc = 0; - crc ^= Seed; + crc ^= SEED; while (--length >= 0) { - crc = Table[(crc ^ data[offset++]) & 0xFF] ^ (crc >> 8); + crc = _table[(crc ^ data[offset++]) & 0xFF] ^ (crc >> 8); } - crc ^= Seed; + crc ^= SEED; return crc; } @@ -280,12 +280,12 @@ public static uint Compute(ReadOnlySpan data, int offset, int length) public static uint Compute(ReadOnlySpan data, int offset, int length) { uint crc = 0; - crc ^= Seed; + crc ^= SEED; while (--length >= 0) { - crc = Table[(crc ^ data[offset++]) & 0xFF] ^ (crc >> 8); + crc = _table[(crc ^ data[offset++]) & 0xFF] ^ (crc >> 8); } - crc ^= Seed; + crc ^= SEED; return crc; } } diff --git a/src/RstbLibrary/ImmutableRstb.cs b/src/RstbLibrary/ImmutableRstb.cs index b2e3922..ca79c66 100644 --- a/src/RstbLibrary/ImmutableRstb.cs +++ b/src/RstbLibrary/ImmutableRstb.cs @@ -39,7 +39,7 @@ public ImmutableRstb(ref RevrsReader reader) private static void Read(ref RevrsReader reader, ref RstbHeader header, out ImmutableHashTable hashTable, out ImmutableOverflowTable overflowTable) { - int hashTableSize = header.HashTableCount * HashEntry.Size; + int hashTableSize = header.HashTableCount * HashEntry.SIZE; int overflowTableSize = header.OverflowTableCount * FIXED_OVERFLOW_ENTRY_SIZE; int expectedFileSize = RstbHeader.SIZE + hashTableSize + overflowTableSize; @@ -48,7 +48,7 @@ private static void Read(ref RevrsReader reader, ref RstbHeader header, out Immu .ReverseEndianness((ushort)reader.Endianness); reader.Reverse(0); - hashTableSize = header.HashTableCount * HashEntry.Size; + hashTableSize = header.HashTableCount * HashEntry.SIZE; overflowTableSize = header.OverflowTableCount * FIXED_OVERFLOW_ENTRY_SIZE; expectedFileSize = RstbHeader.SIZE + hashTableSize + overflowTableSize; @@ -70,7 +70,7 @@ private static void Read(ref RevrsReader reader, ref RstbHeader header, out Immu private static void Read(ref RevrsReader reader, ref RestblHeader header, out ImmutableHashTable hashTable, out ImmutableOverflowTable overflowTable) { - int hashTableSize = header.HashTableCount * HashEntry.Size; + int hashTableSize = header.HashTableCount * HashEntry.SIZE; int overflowTableSize = header.OverflowTableCount * (header.OverflowKeySize + sizeof(uint)); int expectedFileSize = RestblHeader.SIZE + hashTableSize + overflowTableSize; @@ -79,7 +79,7 @@ private static void Read(ref RevrsReader reader, ref RestblHeader header, out Im .ReverseEndianness((ushort)reader.Endianness); reader.Reverse(0); - hashTableSize = header.HashTableCount * HashEntry.Size; + hashTableSize = header.HashTableCount * HashEntry.SIZE; overflowTableSize = header.OverflowTableCount * (header.OverflowKeySize + sizeof(uint)); expectedFileSize = RestblHeader.SIZE + hashTableSize + overflowTableSize; diff --git a/src/RstbLibrary/Structures/HashEntry.cs b/src/RstbLibrary/Structures/HashEntry.cs index 2d5f93d..a1d00b6 100644 --- a/src/RstbLibrary/Structures/HashEntry.cs +++ b/src/RstbLibrary/Structures/HashEntry.cs @@ -2,7 +2,7 @@ public readonly struct HashEntry { - public const int Size = 8; + public const int SIZE = 8; public readonly uint Hash; public readonly uint Value;