Skip to content

Commit

Permalink
improved IsEmptyOrNull implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
luithefirst committed Sep 30, 2024
1 parent 131b8c0 commit 7610f16
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Aardvark.Base/Extensions/IEnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -876,14 +876,13 @@ public static bool AllEqual<T>(this IEnumerable<T> elements)
#region Comparisons

/// <summary>
/// Implemented in System.Interactive.dll.
/// Returns true if elements contains no items or if elements is null,
/// false otherwise.
/// </summary>
public static bool IsEmptyOrNull<T>(this IEnumerable<T> elements)
{
if (elements == null) return true;
return elements.Take(1).Count() == 0;
return !elements.Any(); // will check for ICollection<T> internally
}

public static IEnumerable<T> NonNull<T>(IEnumerable<T> elements)
Expand Down

0 comments on commit 7610f16

Please sign in to comment.