Skip to content

Commit 88c13ac

Browse files
committed
Remove local function allocation.
A captured local variable was causing an unnecessary allocation of a compiler-generated class.
1 parent 4c4baf6 commit 88c13ac

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/MySqlConnector/MySqlClient/Results/ResultSet.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ private ValueTask<Row> ScanRowAsync(IOBehavior ioBehavior, Row row, Cancellation
167167
{
168168
// if we've already read past the end of this resultset, Read returns false
169169
if (BufferState == ResultSetState.HasMoreData || BufferState == ResultSetState.NoMoreData || BufferState == ResultSetState.None)
170-
return new ValueTask<Row>((Row)null);
170+
return new ValueTask<Row>((Row) null);
171171

172172
using (Command.RegisterCancel(cancellationToken))
173173
{
174174
var payloadValueTask = Session.ReceiveReplyAsync(ioBehavior, CancellationToken.None);
175175
return payloadValueTask.IsCompletedSuccessfully
176-
? new ValueTask<Row>(ScanRowAsyncRemainder(payloadValueTask.Result))
177-
: new ValueTask<Row>(ScanRowAsyncAwaited(payloadValueTask.AsTask(), cancellationToken));
176+
? new ValueTask<Row>(ScanRowAsyncRemainder(payloadValueTask.Result, row))
177+
: new ValueTask<Row>(ScanRowAsyncAwaited(payloadValueTask.AsTask(), row, cancellationToken));
178178
}
179179

180-
async Task<Row> ScanRowAsyncAwaited(Task<PayloadData> payloadTask, CancellationToken token)
180+
async Task<Row> ScanRowAsyncAwaited(Task<PayloadData> payloadTask, Row row_, CancellationToken token)
181181
{
182182
PayloadData payloadData;
183183
try
@@ -191,10 +191,10 @@ async Task<Row> ScanRowAsyncAwaited(Task<PayloadData> payloadTask, CancellationT
191191
token.ThrowIfCancellationRequested();
192192
throw;
193193
}
194-
return ScanRowAsyncRemainder(payloadData);
194+
return ScanRowAsyncRemainder(payloadData, row_);
195195
}
196196

197-
Row ScanRowAsyncRemainder(PayloadData payload)
197+
Row ScanRowAsyncRemainder(PayloadData payload, Row row_)
198198
{
199199
if (payload.HeaderByte == EofPayload.Signature)
200200
{
@@ -223,12 +223,12 @@ Row ScanRowAsyncRemainder(PayloadData payload)
223223
reader.Offset += m_dataLengths[column];
224224
}
225225

226-
if (row == null)
227-
row = new Row(this);
228-
row.SetData(m_dataLengths, m_dataOffsets, payload.ArraySegment);
229-
m_rowBuffered = row;
226+
if (row_ == null)
227+
row_ = new Row(this);
228+
row_.SetData(m_dataLengths, m_dataOffsets, payload.ArraySegment);
229+
m_rowBuffered = row_;
230230
m_hasRows = true;
231-
return row;
231+
return row_;
232232
}
233233
}
234234

0 commit comments

Comments
 (0)