Skip to content

Commit e136b03

Browse files
committed
Respond to code review
Exit early if we have no fields to set. Clarify comment.
1 parent 402b207 commit e136b03

File tree

1 file changed

+7
-2
lines changed
  • src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server

1 file changed

+7
-2
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ public virtual int SetValues(params object[] values)
268268
// Allow values array longer than FieldCount, just ignore the extra cells.
269269
int copyLength = (values.Length > FieldCount) ? FieldCount : values.Length;
270270

271+
if (copyLength == 0)
272+
{
273+
return 0;
274+
}
275+
271276
ExtendedClrTypeCode[] typeCodes = new ExtendedClrTypeCode[copyLength];
272277

273278
// Verify all data values as acceptable before changing current state.
@@ -285,8 +290,8 @@ public virtual int SetValues(params object[] values)
285290
}
286291
}
287292

288-
// Now move the data (it'll only throw if someone plays with the values array between
289-
// the validation loop and here, or if an invalid UDT was sent).
293+
// Now move the data. We've already validated the element types above, so this will
294+
// only throw if an invalid UDT was sent.
290295
for (int i = 0; i < copyLength; i++)
291296
{
292297
ValueUtilsSmi.SetCompatibleValueV200(

0 commit comments

Comments
 (0)