Skip to content

Commit

Permalink
feat(sqliteConnection): cache eventargs (#26291)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaeublin committed Nov 16, 2021
1 parent 1c2c60c commit 23630ff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public partial class SqliteConnection : DbConnection
private bool _extensionsEnabled;
private int? _defaultTimeout;

private static readonly StateChangeEventArgs _fromClosedToOpenEventArgs = new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open);
private static readonly StateChangeEventArgs _fromOpenToClosedEventArgs = new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed);

static SqliteConnection()
=> BundleInitializer.Initialize();

Expand Down Expand Up @@ -287,7 +290,7 @@ public override void Open()
throw;
}

OnStateChange(new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open));
OnStateChange(_fromClosedToOpenEventArgs);
}

/// <summary>
Expand Down Expand Up @@ -322,7 +325,7 @@ public override void Close()
_innerConnection = null;

_state = ConnectionState.Closed;
OnStateChange(new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed));
OnStateChange(_fromOpenToClosedEventArgs);
}

internal void Deactivate()
Expand Down

0 comments on commit 23630ff

Please sign in to comment.