Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,18 @@ public double ReadDouble()

public Guid ReadGuid()
{
const int size = 16;
byte* ptr = GetCurrentPointerAndAdvance(size);
byte* ptr = GetCurrentPointerAndAdvance(sizeof(Guid));

#if NET
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that this change is worth it. It is adding ifdef, it is not reducing amount of unsafe code, and it may make the code a bit slower.

return new Guid(MemoryMarshal.CreateReadOnlySpan(ref *ptr, sizeof(Guid)));
#else
if (BitConverter.IsLittleEndian)
{
return *(Guid*)ptr;
}
else
{
Debug.Assert(sizeof(Guid) == 16);
unchecked
{
return new Guid(
Expand All @@ -328,6 +332,7 @@ public Guid ReadGuid()
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
}
}
#endif
}

/// <summary>
Expand Down
Loading