Skip to content

Commit c1ea64c

Browse files
committed
Inline async method and use ValueTask.
1 parent 2186e2f commit c1ea64c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/MySqlConnector/MySqlConnection.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -921,9 +921,12 @@ private async Task DoCloseAsync(bool changeState, IOBehavior ioBehavior)
921921
}
922922
#endif
923923

924+
m_cachedProcedures = null;
925+
924926
try
925927
{
926-
await CloseDatabaseAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
928+
if (m_activeReader is not null || CurrentTransaction is not null)
929+
await CloseDatabaseAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
927930
}
928931
finally
929932
{
@@ -946,15 +949,11 @@ private async Task DoCloseAsync(bool changeState, IOBehavior ioBehavior)
946949
}
947950
}
948951

949-
private Task CloseDatabaseAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
950-
{
951-
m_cachedProcedures = null;
952-
if (m_activeReader is null && CurrentTransaction is null)
953-
return Utility.CompletedTask;
954-
return DoCloseDatabaseAsync(ioBehavior, cancellationToken);
955-
}
956-
957-
private async Task DoCloseDatabaseAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
952+
#if NET45 || NET461 || NET471 || NETSTANDARD1_3 || NETSTANDARD2_0 || NETCOREAPP2_1
953+
private async Task CloseDatabaseAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
954+
#else
955+
private async ValueTask CloseDatabaseAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
956+
#endif
958957
{
959958
if (m_activeReader is not null)
960959
await m_activeReader.DisposeAsync(ioBehavior, cancellationToken).ConfigureAwait(false);

0 commit comments

Comments
 (0)