From f1282f47978c66c08a0548c115208f0120f99191 Mon Sep 17 00:00:00 2001 From: Evgeny Akhtimirov Date: Fri, 19 Jan 2024 16:45:27 +0300 Subject: [PATCH] Perf | avoid copying of an array for SqlGuid in TdsParser (#2308) similar how it's don for netfx --- .../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 8dc72f355c..86d1102ac4 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -5932,7 +5932,11 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt case TdsEnums.SQLUNIQUEID: { Debug.Assert(length == 16, "invalid length for SqlGuid type!"); +#if NET8_0_OR_GREATER value.SqlGuid = new SqlGuid(unencryptedBytes); // doesn't copy the byte array +#else + value.SqlGuid = SqlTypeWorkarounds.SqlGuidCtor(unencryptedBytes, true); // doesn't copy the byte array +#endif break; }