From 39b2f1a2afae9b9ad5cd5378b52488ca86482693 Mon Sep 17 00:00:00 2001 From: Evgeny Akhtimirov Date: Fri, 19 Jan 2024 16:40:23 +0300 Subject: [PATCH] Perf | avoid copying of an array for SqlBinary in TdsParser follow up changes for PR #1934 --- .../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 2090f16a22..8c99d7211e 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 @@ -5953,7 +5953,11 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt unencryptedBytes = bytes; } - value.SqlBinary = new SqlBinary(unencryptedBytes); // doesn't copy the byte array +#if NET7_0_OR_GREATER + value.SqlBinary = SqlBinary.WrapBytes(unencryptedBytes); +#else + value.SqlBinary = SqlTypeWorkarounds.SqlBinaryCtor(unencryptedBytes, true); // doesn't copy the byte array +#endif break; }