Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save atomknack/f131663e7c69f54d03c674a87cef7529 to your computer and use it in GitHub Desktop.
Save atomknack/f131663e7c69f54d03c674a87cef7529 to your computer and use it in GitHub Desktop.
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