Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Mar 16, 2024
1 parent f83cc2f commit bcbaa49
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/RstbLibrary/Helpers/Crc32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -267,25 +267,25 @@ public class Crc32
public static uint Compute(ReadOnlySpan<char> 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;
}

public static uint Compute(ReadOnlySpan<byte> data) => Compute(data, 0, data.Length);
public static uint Compute(ReadOnlySpan<byte> 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;
}
}
8 changes: 4 additions & 4 deletions src/RstbLibrary/ImmutableRstb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -48,7 +48,7 @@ private static void Read(ref RevrsReader reader, ref RstbHeader header, out Immu
.ReverseEndianness((ushort)reader.Endianness);
reader.Reverse<RstbHeader, RstbHeader.Reverser>(0);

hashTableSize = header.HashTableCount * HashEntry.Size;
hashTableSize = header.HashTableCount * HashEntry.SIZE;
overflowTableSize = header.OverflowTableCount * FIXED_OVERFLOW_ENTRY_SIZE;
expectedFileSize = RstbHeader.SIZE + hashTableSize + overflowTableSize;

Expand All @@ -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;

Expand All @@ -79,7 +79,7 @@ private static void Read(ref RevrsReader reader, ref RestblHeader header, out Im
.ReverseEndianness((ushort)reader.Endianness);
reader.Reverse<RestblHeader, RestblHeader.Reverser>(0);

hashTableSize = header.HashTableCount * HashEntry.Size;
hashTableSize = header.HashTableCount * HashEntry.SIZE;
overflowTableSize = header.OverflowTableCount * (header.OverflowKeySize + sizeof(uint));
expectedFileSize = RestblHeader.SIZE + hashTableSize + overflowTableSize;

Expand Down
2 changes: 1 addition & 1 deletion src/RstbLibrary/Structures/HashEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bcbaa49

Please sign in to comment.