Skip to content

Commit

Permalink
快速租用移除容器
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoKyaku committed Jan 9, 2024
1 parent 94b8c31 commit c885b66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Megumin.Explosion/Collections/Generic/DictionaryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,15 @@ public static Remover<K, V> GetForeachRemover<K, V>(this IDictionary<K, V> sourc
{
return new Remover<K, V>(source);
}

public static List<K> RentRemoveList<K, V>(this IDictionary<K, V> source)
{
return ListPool<K>.Shared.Rent();
}

public static void ReturnRemoveList<K, V>(this IDictionary<K, V> source, ref List<K> element, bool forceSafeCheck = false)
{
ListPool<K>.Shared.Return(ref element, forceSafeCheck);
}
}
}
10 changes: 10 additions & 0 deletions Megumin.Explosion/Collections/Generic/IEnumerableExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ public static Remover<T> GetForeachRemover<T>(this ICollection<T> list)
{
return new Remover<T>(list);
}

public static List<T> RentRemoveList<T>(this ICollection<T> list)
{
return ListPool<T>.Shared.Rent();
}

public static void ReturnRemoveList<T>(this ICollection<T> list, ref List<T> element, bool forceSafeCheck = false)
{
ListPool<T>.Shared.Return(ref element, forceSafeCheck);
}
}
}

Expand Down

0 comments on commit c885b66

Please sign in to comment.