Browse Source

Optimization: update SetPostLogoutRedirectUrisAsync() and SetRedirectUrisAsync() to avoid running checks for default or empty arrays

pull/500/head
Kévin Chalet 9 years ago
parent
commit
59b29d2d23
  1. 4
      src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
  2. 20
      src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs

4
src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs

@ -276,7 +276,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken);
ImmutableArray<string> addresses, CancellationToken cancellationToken);
/// <summary>
/// Sets the callback addresses associated with an application.
@ -288,7 +288,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
Task SetRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken);
ImmutableArray<string> addresses, CancellationToken cancellationToken);
/// <summary>
/// Updates an existing application.

20
src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs

@ -555,16 +555,18 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken)
ImmutableArray<string> addresses, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentException(nameof(application));
throw new ArgumentNullException(nameof(application));
}
if (addresses == null)
if (addresses.IsDefaultOrEmpty)
{
throw new ArgumentException(nameof(addresses));
application.PostLogoutRedirectUris = null;
return Task.CompletedTask;
}
if (addresses.Any(address => string.IsNullOrEmpty(address)))
@ -592,16 +594,18 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual Task SetRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken)
ImmutableArray<string> addresses, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentException(nameof(application));
throw new ArgumentNullException(nameof(application));
}
if (addresses == null)
if (addresses.IsDefaultOrEmpty)
{
throw new ArgumentException(nameof(addresses));
application.RedirectUris = null;
return Task.CompletedTask;
}
if (addresses.Any(address => string.IsNullOrEmpty(address)))

Loading…
Cancel
Save