Improved performance of PopFirst and PopLast

This commit is contained in:
Chomp
2025-03-08 10:24:47 +00:00
parent e219ce2ffd
commit 204f9e4525
@@ -11,15 +11,15 @@ public static class ListExtensions
public static T PopFirst<T>(this IList<T> source)
{
var r = source.First();
source.Remove(source.First());
var r = source[0];
source.Remove(source[0]);
return r;
}
public static T PopLast<T>(this IList<T> source)
{
var r = source.Last();
source.Remove(source.Last());
var r = source[^1];
source.Remove(source[^1]);
return r;
}
}