Skip to content

Commit

Permalink
Use UTF-8 literals
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung committed Apr 19, 2024
1 parent 80af170 commit faa1722
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/native/managed/cdacreader/src/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public struct TargetPointer
internal sealed unsafe class Target
{
private const int StackAllocByteThreshold = 1024;
private static readonly ReadOnlyMemory<byte> MagicLE = new byte[] { 0x44, 0x4e, 0x43, 0x43, 0x44, 0x41, 0x43, 0x00 }; // "DNCCDAC\0"
private static readonly ReadOnlyMemory<byte> MagicBE = new byte[] { 0x00, 0x43, 0x41, 0x44, 0x43, 0x43, 0x4e, 0x44 };

private readonly delegate* unmanaged<ulong, byte*, uint, void*, int> _readFromTarget;
private readonly void* _readContext;
Expand All @@ -45,8 +43,10 @@ private void ReadContractDescriptor(ulong address)
throw new InvalidOperationException("Failed to read magic.");

address += sizeof(ulong);
_isLittleEndian = buffer.SequenceEqual(MagicLE.Span);
if (!_isLittleEndian && !buffer.SequenceEqual(MagicBE.Span))
ReadOnlySpan<byte> magicLE = "DNCCDAC\0"u8;
ReadOnlySpan<byte> magicBE = "\0CADCCND"u8;
_isLittleEndian = buffer.SequenceEqual(magicLE);
if (!_isLittleEndian && !buffer.SequenceEqual(magicBE))
throw new InvalidOperationException("Invalid magic.");

// Flags - uint32_t
Expand Down

0 comments on commit faa1722

Please sign in to comment.