Skip to content

Commit 39b2f1a

Browse files
committed
Perf | avoid copying of an array for SqlBinary in TdsParser
follow up changes for PR dotnet#1934
1 parent 41416f5 commit 39b2f1a

File tree

1 file changed

+5
-1
lines changed
  • src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient

1 file changed

+5
-1
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5953,7 +5953,11 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
59535953
unencryptedBytes = bytes;
59545954
}
59555955

5956-
value.SqlBinary = new SqlBinary(unencryptedBytes); // doesn't copy the byte array
5956+
#if NET7_0_OR_GREATER
5957+
value.SqlBinary = SqlBinary.WrapBytes(unencryptedBytes);
5958+
#else
5959+
value.SqlBinary = SqlTypeWorkarounds.SqlBinaryCtor(unencryptedBytes, true); // doesn't copy the byte array
5960+
#endif
59575961
break;
59585962
}
59595963

0 commit comments

Comments
 (0)