C#

C#

Made by DeepSource

Using inefficient methods Min()/Max() on SortedSet<T> CS-P1025

Performance
Major

The methods Min() and Max() come from the Enumerable interface defined in System.Linq. While they may be appropriate for other structures and scenarios, they are not performant for SortedSet<T>. Consider using Sorted<T>'s own properties Min and Max as they're efficient and tailored for this very purpose.

Bad Practice

var min = set.Min();

Recommended

var min = set.Min;

References