Created
June 18, 2023 10:12
-
-
Save atomknack/f131663e7c69f54d03c674a87cef7529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using Collections.Pooled; | |
namespace CollectionLike.Enumerables; | |
public static partial class Enumerables_Extension | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool IsNullOrEmpty(this string s) => | |
String.IsNullOrEmpty(s); | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool IsNullOrEmpty<T>(this PooledList<T> array) => | |
array == null || array.Count == 0; | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool IsNullOrEmpty<T>(this T[] array) => | |
array == null || array.Length == 0; | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool IsNullOrEmpty<T>(this List<T> list) => | |
list == null || list.Count == 0; | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool IsNullOrEmpty<T>(this IList<T> list) => | |
list is null || list.Count == 0; | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool IsNullOrEmpty<T>(this IEnumerable<T> items) => // need testing | |
items is null || !items.Any(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment