Skip to content

Commit

Permalink
Do not allocate for default accept or reject socket connection. (#5108)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed May 31, 2022
1 parent a8add2f commit d4356d3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace HotChocolate.AspNetCore.Subscriptions.Protocols;
/// </summary>
public sealed class ConnectionStatus
{
private static readonly ConnectionStatus _defaultAccepted =
new(true, "You connection was accepted.", null);
private static readonly ConnectionStatus _defaultRejected =
new(false, "Your connection was rejected.", null);

private ConnectionStatus(
bool accepted,
string message,
Expand Down Expand Up @@ -39,7 +44,7 @@ public sealed class ConnectionStatus
/// The connection accept status.
/// </returns>
public static ConnectionStatus Accept()
=> new(true, "You connection was accepted.", null);
=> _defaultAccepted;

/// <summary>
/// Reject the socket connection with a custom message.
Expand Down Expand Up @@ -86,7 +91,7 @@ public static ConnectionStatus Reject(string message)
/// The connection reject status.
/// </returns>
public static ConnectionStatus Reject()
=> Reject("Your connection was rejected.", null);
=> _defaultRejected;

/// <summary>
/// Reject the socket connection with a custom message.
Expand Down

0 comments on commit d4356d3

Please sign in to comment.