Skip to content

Commit

Permalink
Copy byte array as block in Guid ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
xtqqczze committed Jul 21, 2024
1 parent 5eec5ac commit 1f8b8ec
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/libraries/System.Private.CoreLib/src/System/Guid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,13 @@ public Guid(int a, short b, short c, byte[] d)
throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "8"), nameof(d));
}

Unsafe.SkipInit(out this);

_a = a;
_b = b;
_c = c;
_d = d[0];
_e = d[1];
_f = d[2];
_g = d[3];
_h = d[4];
_i = d[5];
_j = d[6];
_k = d[7];

Unsafe.CopyBlockUnaligned(ref _d, ref MemoryMarshal.GetArrayDataReference(d), 8);
}

// Creates a new GUID initialized to the value represented by the
Expand Down

0 comments on commit 1f8b8ec

Please sign in to comment.