Skip to content

Commit

Permalink
Remove enumerator usage in AcquireNextTriggers when getting timeTrigg…
Browse files Browse the repository at this point in the history
…ers min value (#2092)
  • Loading branch information
lahma authored Jul 22, 2023
1 parent 250c2ed commit 66f41a9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

* Mark UseJsonSerializer as obsolete, one should use UseNewtonsoftJsonSerializer (#2077)
* Removed obsolete UseMicrosoftDependencyInjectionScopedJobFactory(), mark UseMicrosoftDependencyInjectionJobFactory() obsolete (#2085)
* Change QuartzHostedService from internal to public (#2090)

* FIXES

* Now omitting UseMicrosoftDependencyInjectionJobFactory() should actually work as it will be the default (#2085)
* Remove enumerator usage in AcquireNextTriggers when getting timeTriggers min value (#2092)


## Release 3.6.3, Jun 25 2023
Expand Down
2 changes: 1 addition & 1 deletion src/Quartz/Simpl/RAMJobStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ public virtual Task<IReadOnlyCollection<IOperableTrigger>> AcquireNextTriggers(

while (true)
{
var tw = timeTriggers.FirstOrDefault();
var tw = timeTriggers.Min;
if (tw == null)
{
break;
Expand Down
28 changes: 1 addition & 27 deletions src/Quartz/Util/SortedSetExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;

namespace Quartz.Util
{
Expand All @@ -9,30 +8,5 @@ internal static SortedSet<int> TailSet(this SortedSet<int> set, int value)
{
return set.GetViewBetween(value, 9999999);
}

/// <summary>
/// Returns the first element of the specified <see cref="SortedSet{TSource}"/>, or a default
/// value if no element is found.
/// </summary>
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
/// <param name="source">The <see cref="SortedSet{TSource}"/> to return the first element of.</param>
/// <returns>
/// The default value for <typeparamref name="TSource"/> if <paramref name="source"/> is empty;
/// otherwise, the first element in <paramref name="source"/>.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
internal static TSource? FirstOrDefault<TSource>(this SortedSet<TSource> source) where TSource : class
{
if (source == null)
throw new ArgumentNullException(nameof(source));

using var enumerator = source.GetEnumerator();
if (!enumerator.MoveNext())
{
return null;
}

return enumerator.Current;
}
}
}

0 comments on commit 66f41a9

Please sign in to comment.