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. /// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application, Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken); ImmutableArray<string> addresses, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the callback addresses associated with an application. /// 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. /// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
Task SetRedirectUrisAsync([NotNull] TApplication application, Task SetRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken); ImmutableArray<string> addresses, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Updates an existing application. /// 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. /// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public virtual Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application, public virtual Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken) ImmutableArray<string> addresses, CancellationToken cancellationToken)
{ {
if (application == null) 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))) 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. /// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
public virtual Task SetRedirectUrisAsync([NotNull] TApplication application, public virtual Task SetRedirectUrisAsync([NotNull] TApplication application,
[NotNull] ImmutableArray<string> addresses, CancellationToken cancellationToken) ImmutableArray<string> addresses, CancellationToken cancellationToken)
{ {
if (application == null) 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))) if (addresses.Any(address => string.IsNullOrEmpty(address)))

Loading…
Cancel
Save