Skip to content

Commit 1f8b8ec

Browse files
committed
Copy byte array as block in Guid ctor
1 parent 5eec5ac commit 1f8b8ec

File tree

1 file changed

+4
-8
lines changed
  • src/libraries/System.Private.CoreLib/src/System

1 file changed

+4
-8
lines changed

src/libraries/System.Private.CoreLib/src/System/Guid.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,13 @@ public Guid(int a, short b, short c, byte[] d)
127127
throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "8"), nameof(d));
128128
}
129129

130+
Unsafe.SkipInit(out this);
131+
130132
_a = a;
131133
_b = b;
132134
_c = c;
133-
_d = d[0];
134-
_e = d[1];
135-
_f = d[2];
136-
_g = d[3];
137-
_h = d[4];
138-
_i = d[5];
139-
_j = d[6];
140-
_k = d[7];
135+
136+
Unsafe.CopyBlockUnaligned(ref _d, ref MemoryMarshal.GetArrayDataReference(d), 8);
141137
}
142138

143139
// Creates a new GUID initialized to the value represented by the

0 commit comments

Comments
 (0)